@vivix-labs/media-tools 1.0.0-beta.21 → 1.0.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -157,3 +157,9 @@ platform guarantees, CI or production release.
157
157
 
158
158
  Compare consumers can provide `slotMenuItems(slot)` for business actions in each
159
159
  column menu. `renderSlotActions` remains supported for existing consumers.
160
+
161
+ ## Sequence subtitles
162
+
163
+ `sequence.process` accepts an optional `subtitle` with a fixed project asset file and whole-film style. `subtitles.preview` takes the same track and output canvas and returns timed transparent images. Preview and export use the same glyphs, wrapping and positions. UTF-8 SRT and ASS dialogue text are supported. ASS style overrides are discarded. Use a subtitle attachment or import a primary file with purpose `subtitle`.
164
+
165
+ The renderer bundles Noto Sans SC from `@fontsource/noto-sans-sc@5.3.1` under the SIL Open Font License, opentype.js under MIT and resvg-js WASM under MPL-2.0. See `resources/` for notices.
@@ -49,39 +49,54 @@ function exportName(name, extension) {
49
49
  }
50
50
 
51
51
  // packages/media-tools/src/shared.ts
52
- import { z, PluginError, studioFileRef } from "vivix-studio/sdk/shared";
53
- var Config = z.object({
54
- dataInstance: z.string().min(1).default("user:data"),
55
- studioInstance: z.string().min(1).default("studio"),
56
- executionNamespace: z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/).default("media"),
57
- ffmpegPath: z.string().min(1).default("ffmpeg"),
58
- ffprobePath: z.string().min(1).default("ffprobe")
59
- }).strict();
52
+ import { z as z3, PluginError, studioFileRef } from "vivix-studio/sdk/shared";
53
+
54
+ // packages/media-tools/src/file-ref.ts
55
+ import { z } from "vivix-studio/sdk/shared";
60
56
  var versionRef = z.object({ storeId: z.uuid(), objectId: z.uuid(), versionId: z.uuid() }).strict();
61
57
  var videoFileRef = z.object({ source: versionRef, fileId: z.uuid() }).strict();
62
- var sourceInput = z.object({ kind: z.literal("source"), file: videoFileRef }).strict();
63
- var editInput = z.object({ kind: z.literal("edit"), editRef: versionRef }).strict();
64
- var videoInput = z.discriminatedUnion("kind", [sourceInput, editInput]);
65
- var sequenceVideoInput = z.discriminatedUnion("kind", [
66
- sourceInput.extend({ trimEndMs: z.number().int().positive().optional() }),
58
+
59
+ // packages/media-tools/src/subtitle-track.ts
60
+ import { z as z2 } from "vivix-studio/sdk/shared";
61
+ var subtitleStyle = z2.object({
62
+ size: z2.number().int().min(32).max(80).default(52),
63
+ position: z2.enum(["top", "middle", "bottom"]).default("bottom"),
64
+ color: z2.string().regex(/^#[0-9a-f]{6}$/i).default("#ffffff"),
65
+ background: z2.boolean().default(false)
66
+ }).strict();
67
+ var subtitleTrack = z2.object({ file: videoFileRef, style: subtitleStyle.default(() => subtitleStyle.parse({})) }).strict();
68
+
69
+ // packages/media-tools/src/shared.ts
70
+ var Config = z3.object({
71
+ dataInstance: z3.string().min(1).default("user:data"),
72
+ studioInstance: z3.string().min(1).default("studio"),
73
+ executionNamespace: z3.string().regex(/^[a-zA-Z0-9_-]{1,64}$/).default("media"),
74
+ ffmpegPath: z3.string().min(1).default("ffmpeg"),
75
+ ffprobePath: z3.string().min(1).default("ffprobe")
76
+ }).strict();
77
+ var sourceInput = z3.object({ kind: z3.literal("source"), file: videoFileRef }).strict();
78
+ var editInput = z3.object({ kind: z3.literal("edit"), editRef: versionRef }).strict();
79
+ var videoInput = z3.discriminatedUnion("kind", [sourceInput, editInput]);
80
+ var sequenceVideoInput = z3.discriminatedUnion("kind", [
81
+ sourceInput.extend({ trimEndMs: z3.number().int().positive().optional() }),
67
82
  editInput
68
83
  ]);
69
- var colorAdjustment = z.object({
70
- brightness: z.number().finite().min(-0.5).max(0.5),
71
- contrast: z.number().finite().min(0).max(2),
72
- saturation: z.number().finite().min(0).max(2)
84
+ var colorAdjustment = z3.object({
85
+ brightness: z3.number().finite().min(-0.5).max(0.5),
86
+ contrast: z3.number().finite().min(0).max(2),
87
+ saturation: z3.number().finite().min(0).max(2)
73
88
  }).strict();
74
89
  var neutralColor = { brightness: 0, contrast: 1, saturation: 1 };
75
- var recipe = z.object({
76
- trim: z.object({ inMs: z.number().int().nonnegative(), outMs: z.number().int().positive() }).strict(),
77
- crop: z.object({
78
- x: z.number().finite().nonnegative(),
79
- y: z.number().finite().nonnegative(),
80
- width: z.number().finite().positive().max(1),
81
- height: z.number().finite().positive().max(1)
90
+ var recipe = z3.object({
91
+ trim: z3.object({ inMs: z3.number().int().nonnegative(), outMs: z3.number().int().positive() }).strict(),
92
+ crop: z3.object({
93
+ x: z3.number().finite().nonnegative(),
94
+ y: z3.number().finite().nonnegative(),
95
+ width: z3.number().finite().positive().max(1),
96
+ height: z3.number().finite().positive().max(1)
82
97
  }).strict(),
83
98
  color: colorAdjustment.optional(),
84
- speed: z.number().finite().min(0.25).max(4).optional()
99
+ speed: z3.number().finite().min(0.25).max(4).optional()
85
100
  }).strict().superRefine((v, c) => {
86
101
  if (v.trim.inMs >= v.trim.outMs)
87
102
  c.addIssue({ code: "custom", message: "The selected interval must have positive duration." });
@@ -97,62 +112,62 @@ var videoEditorTitles = {
97
112
  color: "Adjust Color",
98
113
  speed: "Video Speed"
99
114
  };
100
- var pixelRect = z.object({
101
- x: z.number().int().nonnegative(),
102
- y: z.number().int().nonnegative(),
103
- width: z.number().int().positive(),
104
- height: z.number().int().positive()
115
+ var pixelRect = z3.object({
116
+ x: z3.number().int().nonnegative(),
117
+ y: z3.number().int().nonnegative(),
118
+ width: z3.number().int().positive(),
119
+ height: z3.number().int().positive()
105
120
  }).strict();
106
- var geometry = z.object({
107
- displayWidth: z.number().int().positive(),
108
- displayHeight: z.number().int().positive(),
121
+ var geometry = z3.object({
122
+ displayWidth: z3.number().int().positive(),
123
+ displayHeight: z3.number().int().positive(),
109
124
  pixelRect
110
125
  }).strict();
111
- var metadata = z.object({
112
- durationMs: z.number().int().positive(),
113
- width: z.number().int().positive(),
114
- height: z.number().int().positive(),
115
- displayWidth: z.number().int().positive(),
116
- displayHeight: z.number().int().positive(),
117
- rotation: z.union([z.literal(0), z.literal(90), z.literal(180), z.literal(270)]),
118
- frameRate: z.number().positive().max(60),
119
- startTime: z.number().finite(),
120
- hasAudio: z.boolean(),
121
- audioSampleRate: z.number().int().nullable(),
122
- audioChannels: z.number().int().nullable(),
123
- audioStartTime: z.number().finite().nullable(),
124
- sizeBytes: z.number().int().nonnegative(),
125
- sha256: z.string().regex(/^[a-f0-9]{64}$/),
126
- colorInterpretation: z.enum(["declared-bt709", "assumed-bt709"]).optional()
126
+ var metadata = z3.object({
127
+ durationMs: z3.number().int().positive(),
128
+ width: z3.number().int().positive(),
129
+ height: z3.number().int().positive(),
130
+ displayWidth: z3.number().int().positive(),
131
+ displayHeight: z3.number().int().positive(),
132
+ rotation: z3.union([z3.literal(0), z3.literal(90), z3.literal(180), z3.literal(270)]),
133
+ frameRate: z3.number().positive().max(60),
134
+ startTime: z3.number().finite(),
135
+ hasAudio: z3.boolean(),
136
+ audioSampleRate: z3.number().int().nullable(),
137
+ audioChannels: z3.number().int().nullable(),
138
+ audioStartTime: z3.number().finite().nullable(),
139
+ sizeBytes: z3.number().int().nonnegative(),
140
+ sha256: z3.string().regex(/^[a-f0-9]{64}$/),
141
+ colorInterpretation: z3.enum(["declared-bt709", "assumed-bt709"]).optional()
127
142
  }).strict();
128
- var editDescriptor = z.object({ format: z.literal(1), file: videoFileRef, recipe, geometry, metadata }).strict();
129
- var saveEdit = z.object({
143
+ var editDescriptor = z3.object({ format: z3.literal(1), file: videoFileRef, recipe, geometry, metadata }).strict();
144
+ var saveEdit = z3.object({
130
145
  file: videoFileRef,
131
146
  recipe,
132
- editId: z.uuid().optional(),
133
- expectedRevision: z.number().int().positive().optional()
147
+ editId: z3.uuid().optional(),
148
+ expectedRevision: z3.number().int().positive().optional()
134
149
  }).strict().superRefine((v, c) => {
135
150
  if (Boolean(v.editId) !== Boolean(v.expectedRevision))
136
151
  c.addIssue({ code: "custom", message: "An edit update requires its revision." });
137
152
  });
138
- var outputName = z.string().trim().min(1).max(200);
139
- var gain = z.number().finite().min(-96).max(24);
140
- var milliseconds = z.number().int().min(0).max(6e5);
141
- var audioMix = z.object({
142
- version: z.literal(1),
153
+ var outputName = z3.string().trim().min(1).max(200);
154
+ var gain = z3.number().finite().min(-96).max(24);
155
+ var milliseconds = z3.number().int().min(0).max(6e5);
156
+ var audioMix = z3.object({
157
+ version: z3.literal(1),
143
158
  originalGainDb: gain.nullable().optional(),
144
- originals: z.array(
145
- z.object({
146
- inputIndex: z.number().int().min(0).max(63),
159
+ originals: z3.array(
160
+ z3.object({
161
+ inputIndex: z3.number().int().min(0).max(63),
147
162
  gainDb: gain.nullable(),
148
- role: z.enum(["dialogue", "ambience"]).optional()
163
+ role: z3.enum(["dialogue", "ambience"]).optional()
149
164
  }).strict()
150
165
  ).max(64).optional(),
151
- tracks: z.array(
152
- z.object({
153
- id: z.string().trim().min(1).max(128),
166
+ tracks: z3.array(
167
+ z3.object({
168
+ id: z3.string().trim().min(1).max(128),
154
169
  file: videoFileRef,
155
- role: z.enum(["narration", "music", "sfx"]),
170
+ role: z3.enum(["narration", "music", "sfx"]),
156
171
  atMs: milliseconds,
157
172
  inMs: milliseconds.optional(),
158
173
  outMs: milliseconds.optional(),
@@ -161,87 +176,88 @@ var audioMix = z.object({
161
176
  fadeOutMs: milliseconds.optional()
162
177
  }).strict()
163
178
  ).max(32),
164
- ducking: z.boolean().optional(),
165
- loudness: z.enum(["studio-web-v1", "off"]).optional()
179
+ ducking: z3.boolean().optional(),
180
+ loudness: z3.enum(["studio-web-v1", "off"]).optional()
166
181
  }).strict();
167
182
  var maxSequenceInputs = 64;
168
- var audioQuery = z.object({ inputs: z.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
183
+ var audioQuery = z3.object({ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
169
184
  var previewQuery = audioQuery.extend({
170
- knownRevision: z.number().int().nonnegative().optional()
185
+ knownRevision: z3.number().int().nonnegative().optional()
171
186
  });
172
- var audioPreviewResult = z.discriminatedUnion("state", [
173
- z.object({ state: z.literal("original"), revision: z.number() }),
174
- z.object({ state: z.literal("unchanged") }),
175
- z.object({ state: z.literal("preparing") }),
176
- z.object({
177
- state: z.literal("ready"),
178
- revision: z.number(),
187
+ var audioPreviewResult = z3.discriminatedUnion("state", [
188
+ z3.object({ state: z3.literal("original"), revision: z3.number() }),
189
+ z3.object({ state: z3.literal("unchanged") }),
190
+ z3.object({ state: z3.literal("preparing") }),
191
+ z3.object({
192
+ state: z3.literal("ready"),
193
+ revision: z3.number(),
179
194
  file: studioFileRef().nullable(),
180
- segments: z.array(z.object({ startMs: z.number(), durationMs: z.number().positive() }))
195
+ segments: z3.array(z3.object({ startMs: z3.number(), durationMs: z3.number().positive() }))
181
196
  })
182
197
  ]);
183
198
  var saveAudio = audioQuery.extend({
184
- expectedRevision: z.number().int().nonnegative(),
199
+ expectedRevision: z3.number().int().nonnegative(),
185
200
  mix: audioMix.nullable()
186
201
  });
187
- var remixRequest = z.object({
188
- basis: z.enum(["sources", "master"]),
202
+ var remixRequest = z3.object({
203
+ basis: z3.enum(["sources", "master"]),
189
204
  mix: audioMix,
190
- expectedAssetRevision: z.number().int().positive(),
191
- expectedMixRevision: z.number().int().nonnegative()
205
+ expectedAssetRevision: z3.number().int().positive(),
206
+ expectedMixRevision: z3.number().int().nonnegative()
192
207
  }).strict();
193
- var processVideo = z.object({
208
+ var processVideo = z3.object({
194
209
  input: videoInput,
195
210
  outputName,
196
- retryOfJobId: z.uuid().optional(),
211
+ retryOfJobId: z3.uuid().optional(),
197
212
  remix: remixRequest.optional()
198
213
  }).strict().refine((v) => !v.remix || v.input.kind === "source", "Remix requires a fixed source file.");
199
- var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.number().int().min(2).max(3840) }).strict().refine(
214
+ var canvas = z3.object({ width: z3.number().int().min(2).max(3840), height: z3.number().int().min(2).max(3840) }).strict().refine(
200
215
  (v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
201
216
  "Canvas dimensions must be even and within 3840 by 2160."
202
217
  );
203
- var exportFormat = z.enum(
218
+ var exportFormat = z3.enum(
204
219
  Object.keys(exportProfiles)
205
220
  );
206
- var exportSettings = z.object({
221
+ var exportSettings = z3.object({
207
222
  format: exportFormat,
208
- aspect: z.enum(exportAspects),
209
- resolution: z.union([
210
- z.literal("source"),
211
- z.literal(480),
212
- z.literal(720),
213
- z.literal(1080),
214
- z.literal(2160)
223
+ aspect: z3.enum(exportAspects),
224
+ resolution: z3.union([
225
+ z3.literal("source"),
226
+ z3.literal(480),
227
+ z3.literal(720),
228
+ z3.literal(1080),
229
+ z3.literal(2160)
215
230
  ]),
216
- frameRate: z.union([
217
- z.literal("source"),
218
- z.literal(24),
219
- z.literal(25),
220
- z.literal(30),
221
- z.literal(50),
222
- z.literal(60)
231
+ frameRate: z3.union([
232
+ z3.literal("source"),
233
+ z3.literal(24),
234
+ z3.literal(25),
235
+ z3.literal(30),
236
+ z3.literal(50),
237
+ z3.literal(60)
223
238
  ]),
224
- quality: z.enum(exportQualities),
225
- audio: z.boolean()
239
+ quality: z3.enum(exportQualities),
240
+ audio: z3.boolean()
226
241
  }).strict();
227
- var processSequence = z.object({
228
- inputs: z.array(sequenceVideoInput).min(1).max(maxSequenceInputs),
242
+ var processSequence = z3.object({
243
+ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs),
229
244
  outputName,
230
245
  canvas,
246
+ subtitle: subtitleTrack.optional(),
231
247
  settings: exportSettings.optional(),
232
- retryOfJobId: z.uuid().optional()
248
+ retryOfJobId: z3.uuid().optional()
233
249
  }).strict();
234
- var mediaRequest = z.discriminatedUnion("operation", [
235
- z.object({ operation: z.literal("video.process"), input: processVideo }).strict(),
236
- z.object({ operation: z.literal("sequence.process"), input: processSequence }).strict()
250
+ var mediaRequest = z3.discriminatedUnion("operation", [
251
+ z3.object({ operation: z3.literal("video.process"), input: processVideo }).strict(),
252
+ z3.object({ operation: z3.literal("sequence.process"), input: processSequence }).strict()
237
253
  ]);
238
- var jobsQuery = z.object({
239
- limit: z.number().int().min(1).max(100).default(50),
240
- offset: z.number().int().nonnegative().default(0),
241
- request: z.object({
242
- operation: z.enum(["video.process", "sequence.process"]),
243
- requestKey: z.string().min(1).max(128),
244
- intent: z.union([processVideo, processSequence])
254
+ var jobsQuery = z3.object({
255
+ limit: z3.number().int().min(1).max(100).default(50),
256
+ offset: z3.number().int().nonnegative().default(0),
257
+ request: z3.object({
258
+ operation: z3.enum(["video.process", "sequence.process"]),
259
+ requestKey: z3.string().min(1).max(128),
260
+ intent: z3.union([processVideo, processSequence])
245
261
  }).strict().optional()
246
262
  }).strict();
247
263
  function mediaError(code, message) {
@@ -907,7 +923,7 @@ function useInlineDialog(anchor) {
907
923
  }, [anchor]);
908
924
  return inline;
909
925
  }
910
- function Dialog({ title, open, onOpenChange, children, actions, className, inlineWhenClosed = false, variant = "default", closeOnEscape = true, focusTitleOnOpen = variant === "welcome" }) {
926
+ function Dialog({ title, titleBadge, open, onOpenChange, children, actions, className, inlineWhenClosed = false, variant = "default", closeOnEscape = true, focusTitleOnOpen = variant === "welcome" }) {
911
927
  const ref = useRef2(null);
912
928
  const anchor = useRef2(null);
913
929
  const [surface, setSurface] = useState3();
@@ -958,7 +974,7 @@ function Dialog({ title, open, onOpenChange, children, actions, className, inlin
958
974
  }, onClose: (event) => {
959
975
  if (open && event.currentTarget.isConnected && !event.currentTarget.open)
960
976
  onOpenChange(false);
961
- }, children: [_jsxs8("header", { hidden: inlineWhenClosed && !open, children: [_jsx9("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), !welcome && closeButton] }), _jsx9("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs8("footer", { hidden: inlineWhenClosed && !open, children: [actions, welcome && closeButton] })] });
977
+ }, children: [_jsxs8("header", { hidden: inlineWhenClosed && !open, children: [_jsx9("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), titleBadge, !welcome && closeButton] }), _jsx9("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs8("footer", { hidden: inlineWhenClosed && !open, children: [actions, welcome && closeButton] })] });
962
978
  return _jsxs8(_Fragment3, { children: [_jsx9("span", { ref: anchor, hidden: true }), (open || inlineWhenClosed) && (surface ? createPortal(dialog, surface) : dialog)] });
963
979
  }
964
980
 
@@ -2253,6 +2269,7 @@ var idleTracking = { jobId: void 0, downloadPending: false, pending: void 0 };
2253
2269
  function VideoExport({
2254
2270
  title,
2255
2271
  preview,
2272
+ renderPreview,
2256
2273
  canvas: canvas2,
2257
2274
  issue,
2258
2275
  legacyTracking,
@@ -2379,7 +2396,9 @@ function VideoExport({
2379
2396
  };
2380
2397
  }, [client, instanceId, jobId, job?.state, unresolved, downloadPending]);
2381
2398
  function updateJob(result, shouldDownload) {
2382
- const notice2 = exportNotices[result.state];
2399
+ const subtitleError = result.state === "failed" && result.error?.code === "INVALID_SUBTITLE" ? result.error.message : void 0;
2400
+ if (subtitleError) setError(subtitleError);
2401
+ const notice2 = subtitleError ?? exportNotices[result.state];
2383
2402
  if (notice2 && notifiedFailure.current !== result.jobId) {
2384
2403
  notifiedFailure.current = result.jobId;
2385
2404
  showNotice(
@@ -2582,7 +2601,7 @@ function VideoExport({
2582
2601
  ))
2583
2602
  },
2584
2603
  /* @__PURE__ */ React5.createElement(Toast, { message: notice }),
2585
- /* @__PURE__ */ React5.createElement("div", { className: "mt-export-layout" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-export-preview", style: previewStyle }, preview), /* @__PURE__ */ React5.createElement("div", { className: "mt-export-options" }, /* @__PURE__ */ React5.createElement(
2604
+ /* @__PURE__ */ React5.createElement("div", { className: "mt-export-layout" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-export-preview", style: previewStyle }, renderPreview ? renderPreview(dimensions ?? void 0) : preview), /* @__PURE__ */ React5.createElement("div", { className: "mt-export-options" }, /* @__PURE__ */ React5.createElement(
2586
2605
  TextInput,
2587
2606
  {
2588
2607
  placeholder: "Enter a title for the exported video",
@@ -3066,6 +3085,7 @@ async function activate(client) {
3066
3085
  client.provide({
3067
3086
  capabilityVersion: "media-tools/client/1",
3068
3087
  resolve,
3088
+ previewSubtitle: (subtitle, canvas2) => client.invoke({ instanceId, operationId: "subtitles.preview" }, { subtitle, canvas: canvas2 }),
3069
3089
  submit: (request, requestKey) => submitOrFind(client, instanceId, request, requestKey)
3070
3090
  });
3071
3091
  const listeners = /* @__PURE__ */ new Set();
package/dist/client.css CHANGED
@@ -3483,6 +3483,9 @@ button.vx-tile-title {
3483
3483
  margin: 0;
3484
3484
  font: var(--vx-typography-inter-18-semi-bold);
3485
3485
  }
3486
+ .vx-dialog > header > :nth-child(2):not(:last-child) {
3487
+ margin-inline-end: auto;
3488
+ }
3486
3489
  dialog.vx-dialog.vx-dialog-inline {
3487
3490
  position: static;
3488
3491
  display: block;
package/dist/client.d.ts CHANGED
@@ -4,6 +4,7 @@ export { Config } from './shared.js';
4
4
  import * as React from 'react';
5
5
  import 'vivix-studio/sdk/shared';
6
6
  import '@vivix-labs/ui-system';
7
+ import './subtitle-track.js';
7
8
 
8
9
  declare function VideoEditor({ input, mode, onApply, onClose }: VideoEditorProps): React.JSX.Element;
9
10
 
package/dist/server.d.ts CHANGED
@@ -5,6 +5,7 @@ import 'react';
5
5
  import 'vivix-studio/sdk/client';
6
6
  import 'vivix-studio/sdk/shared';
7
7
  import '@vivix-labs/ui-system';
8
+ import './subtitle-track.js';
8
9
 
9
10
  declare const dependencies: (config: MediaToolsConfig) => string[];
10
11
  declare function activate(ctx: ServerContext<MediaToolsConfig>): Promise<void>;