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

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/dist/shared.d.ts CHANGED
@@ -3,6 +3,8 @@ import { ReactNode } from 'react';
3
3
  import { ClientContext } from 'vivix-studio/sdk/client';
4
4
  import { CallContext as CallContext$1, z } from 'vivix-studio/sdk/shared';
5
5
  import { MenuItem } from '@vivix-labs/ui-system';
6
+ import { SubtitleTrack, SubtitlePreview } from './subtitle-track.js';
7
+ export { subtitleStyle, subtitleTrack } from './subtitle-track.js';
6
8
 
7
9
  type SequenceSound = {
8
10
  state: 'original' | 'loading';
@@ -237,15 +239,6 @@ interface DataAPI {
237
239
  purge(id: string, revision: number, call: CallContext): any;
238
240
  }
239
241
 
240
- declare const packageVersion = "0.1.22-ecommerce.20261110.1";
241
- declare const Config: z.ZodObject<{
242
- dataInstance: z.ZodDefault<z.ZodString>;
243
- studioInstance: z.ZodDefault<z.ZodString>;
244
- executionNamespace: z.ZodDefault<z.ZodString>;
245
- ffmpegPath: z.ZodDefault<z.ZodString>;
246
- ffprobePath: z.ZodDefault<z.ZodString>;
247
- }, z.core.$strict>;
248
- type MediaToolsConfig = z.infer<typeof Config>;
249
242
  declare const versionRef: z.ZodObject<{
250
243
  storeId: z.ZodUUID;
251
244
  objectId: z.ZodUUID;
@@ -260,6 +253,16 @@ declare const videoFileRef: z.ZodObject<{
260
253
  fileId: z.ZodUUID;
261
254
  }, z.core.$strict>;
262
255
  type VideoFileRef = z.infer<typeof videoFileRef>;
256
+
257
+ declare const packageVersion = "0.1.22-ecommerce.20261110.1";
258
+ declare const Config: z.ZodObject<{
259
+ dataInstance: z.ZodDefault<z.ZodString>;
260
+ studioInstance: z.ZodDefault<z.ZodString>;
261
+ executionNamespace: z.ZodDefault<z.ZodString>;
262
+ ffmpegPath: z.ZodDefault<z.ZodString>;
263
+ ffprobePath: z.ZodDefault<z.ZodString>;
264
+ }, z.core.$strict>;
265
+ type MediaToolsConfig = z.infer<typeof Config>;
263
266
  declare const videoInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
264
267
  kind: z.ZodLiteral<"source">;
265
268
  file: z.ZodObject<{
@@ -776,6 +779,26 @@ declare const processSequence: z.ZodObject<{
776
779
  width: z.ZodNumber;
777
780
  height: z.ZodNumber;
778
781
  }, z.core.$strict>;
782
+ subtitle: z.ZodOptional<z.ZodObject<{
783
+ file: z.ZodObject<{
784
+ source: z.ZodObject<{
785
+ storeId: z.ZodUUID;
786
+ objectId: z.ZodUUID;
787
+ versionId: z.ZodUUID;
788
+ }, z.core.$strict>;
789
+ fileId: z.ZodUUID;
790
+ }, z.core.$strict>;
791
+ style: z.ZodDefault<z.ZodObject<{
792
+ size: z.ZodDefault<z.ZodNumber>;
793
+ position: z.ZodDefault<z.ZodEnum<{
794
+ top: "top";
795
+ middle: "middle";
796
+ bottom: "bottom";
797
+ }>>;
798
+ color: z.ZodDefault<z.ZodString>;
799
+ background: z.ZodDefault<z.ZodBoolean>;
800
+ }, z.core.$strict>>;
801
+ }, z.core.$strict>>;
779
802
  settings: z.ZodOptional<z.ZodObject<{
780
803
  format: z.ZodEnum<{
781
804
  h264: "h264";
@@ -909,6 +932,26 @@ declare const mediaRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
909
932
  width: z.ZodNumber;
910
933
  height: z.ZodNumber;
911
934
  }, z.core.$strict>;
935
+ subtitle: z.ZodOptional<z.ZodObject<{
936
+ file: z.ZodObject<{
937
+ source: z.ZodObject<{
938
+ storeId: z.ZodUUID;
939
+ objectId: z.ZodUUID;
940
+ versionId: z.ZodUUID;
941
+ }, z.core.$strict>;
942
+ fileId: z.ZodUUID;
943
+ }, z.core.$strict>;
944
+ style: z.ZodDefault<z.ZodObject<{
945
+ size: z.ZodDefault<z.ZodNumber>;
946
+ position: z.ZodDefault<z.ZodEnum<{
947
+ top: "top";
948
+ middle: "middle";
949
+ bottom: "bottom";
950
+ }>>;
951
+ color: z.ZodDefault<z.ZodString>;
952
+ background: z.ZodDefault<z.ZodBoolean>;
953
+ }, z.core.$strict>>;
954
+ }, z.core.$strict>>;
912
955
  settings: z.ZodOptional<z.ZodObject<{
913
956
  format: z.ZodEnum<{
914
957
  h264: "h264";
@@ -1060,6 +1103,26 @@ declare const jobsQuery: z.ZodObject<{
1060
1103
  width: z.ZodNumber;
1061
1104
  height: z.ZodNumber;
1062
1105
  }, z.core.$strict>;
1106
+ subtitle: z.ZodOptional<z.ZodObject<{
1107
+ file: z.ZodObject<{
1108
+ source: z.ZodObject<{
1109
+ storeId: z.ZodUUID;
1110
+ objectId: z.ZodUUID;
1111
+ versionId: z.ZodUUID;
1112
+ }, z.core.$strict>;
1113
+ fileId: z.ZodUUID;
1114
+ }, z.core.$strict>;
1115
+ style: z.ZodDefault<z.ZodObject<{
1116
+ size: z.ZodDefault<z.ZodNumber>;
1117
+ position: z.ZodDefault<z.ZodEnum<{
1118
+ top: "top";
1119
+ middle: "middle";
1120
+ bottom: "bottom";
1121
+ }>>;
1122
+ color: z.ZodDefault<z.ZodString>;
1123
+ background: z.ZodDefault<z.ZodBoolean>;
1124
+ }, z.core.$strict>>;
1125
+ }, z.core.$strict>>;
1063
1126
  settings: z.ZodOptional<z.ZodObject<{
1064
1127
  format: z.ZodEnum<{
1065
1128
  h264: "h264";
@@ -1095,6 +1158,10 @@ interface JobPage {
1095
1158
  interface VideoExportProps {
1096
1159
  title: string;
1097
1160
  preview: React.ReactNode;
1161
+ renderPreview?(canvas?: {
1162
+ width: number;
1163
+ height: number;
1164
+ }): React.ReactNode;
1098
1165
  aspectRatio?: string;
1099
1166
  canvas?: ProcessSequence['canvas'];
1100
1167
  issue?: string;
@@ -1169,9 +1236,13 @@ declare function sameFile(a: VideoFileRef, b: VideoFileRef): boolean;
1169
1236
  type EditReadData = Readonly<Pick<DataAPI, 'storeId' | 'scope' | 'get' | 'version' | 'files'>>;
1170
1237
  declare function readSavedEdit(data: EditReadData, raw: VersionRef): SavedEdit;
1171
1238
  interface MediaToolsClient {
1239
+ previewSubtitle?(subtitle: SubtitleTrack, canvas: {
1240
+ width: number;
1241
+ height: number;
1242
+ }): Promise<SubtitlePreview>;
1172
1243
  readonly capabilityVersion: 'media-tools/client/1';
1173
1244
  submit(request: MediaRequest, requestKey: string): Promise<AcceptedJob>;
1174
1245
  resolve(input: VideoInput): Promise<ResolvedVideo>;
1175
1246
  }
1176
1247
 
1177
- export { type AcceptedJob, type AudioMix, type AudioPreviewResult, type CompareSlot, Config, type EditDescriptor, type EditReadData, type ExportSettings, type Geometry, type JobPage, type JobState, type MediaJob, type MediaJobsProps, type MediaRequest, type MediaToolsClient, type MediaToolsConfig, type MediaToolsService, type PixelRect, type ProcessSequence, type ProcessVideo, type Recipe, type ResolvedVideo, type SaveEdit, type SavedEdit, type SequenceSound, type SequenceVideoInput, type VideoCompareProps, type VideoEditorProps, type VideoExportProps, type VideoFileRef, type VideoInput, type VideoMetadata, audioMix, audioPreviewResult, audioQuery, canvas, colorAdjustment, editDescriptor, exportFormat, exportSettings, geometry, jobStates, jobsQuery, maxSequenceInputs, mediaError, mediaRequest, metadata, neutralColor, normalizeRecipe, packageVersion, previewQuery, processSequence, processVideo, readSavedEdit, recipe, recipeDurationMs, sameFile, saveAudio, saveEdit, sequenceVideoInput, versionRef, videoEditorTitles, videoFileRef, videoInput, watchSequenceSound };
1248
+ export { type AcceptedJob, type AudioMix, type AudioPreviewResult, type CompareSlot, Config, type EditDescriptor, type EditReadData, type ExportSettings, type Geometry, type JobPage, type JobState, type MediaJob, type MediaJobsProps, type MediaRequest, type MediaToolsClient, type MediaToolsConfig, type MediaToolsService, type PixelRect, type ProcessSequence, type ProcessVideo, type Recipe, type ResolvedVideo, type SaveEdit, type SavedEdit, type SequenceSound, type SequenceVideoInput, SubtitlePreview, SubtitleTrack, type VideoCompareProps, type VideoEditorProps, type VideoExportProps, type VideoFileRef, type VideoInput, type VideoMetadata, audioMix, audioPreviewResult, audioQuery, canvas, colorAdjustment, editDescriptor, exportFormat, exportSettings, geometry, jobStates, jobsQuery, maxSequenceInputs, mediaError, mediaRequest, metadata, neutralColor, normalizeRecipe, packageVersion, previewQuery, processSequence, processVideo, readSavedEdit, recipe, recipeDurationMs, sameFile, saveAudio, saveEdit, sequenceVideoInput, versionRef, videoEditorTitles, videoFileRef, videoInput, watchSequenceSound };
package/dist/shared.js CHANGED
@@ -105,40 +105,55 @@ var exportAspects = ["source", "16:9", "9:16", "1:1", "4:3", "3:4", "21:9"];
105
105
  var exportQualities = ["high", "standard", "small"];
106
106
 
107
107
  // packages/media-tools/src/shared.ts
108
- import { z, PluginError, studioFileRef } from "vivix-studio/sdk/shared";
109
- var packageVersion = "0.1.22-ecommerce.20261110.1";
110
- var Config = z.object({
111
- dataInstance: z.string().min(1).default("user:data"),
112
- studioInstance: z.string().min(1).default("studio"),
113
- executionNamespace: z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/).default("media"),
114
- ffmpegPath: z.string().min(1).default("ffmpeg"),
115
- ffprobePath: z.string().min(1).default("ffprobe")
116
- }).strict();
108
+ import { z as z3, PluginError, studioFileRef } from "vivix-studio/sdk/shared";
109
+
110
+ // packages/media-tools/src/file-ref.ts
111
+ import { z } from "vivix-studio/sdk/shared";
117
112
  var versionRef = z.object({ storeId: z.uuid(), objectId: z.uuid(), versionId: z.uuid() }).strict();
118
113
  var videoFileRef = z.object({ source: versionRef, fileId: z.uuid() }).strict();
119
- var sourceInput = z.object({ kind: z.literal("source"), file: videoFileRef }).strict();
120
- var editInput = z.object({ kind: z.literal("edit"), editRef: versionRef }).strict();
121
- var videoInput = z.discriminatedUnion("kind", [sourceInput, editInput]);
122
- var sequenceVideoInput = z.discriminatedUnion("kind", [
123
- sourceInput.extend({ trimEndMs: z.number().int().positive().optional() }),
114
+
115
+ // packages/media-tools/src/subtitle-track.ts
116
+ import { z as z2 } from "vivix-studio/sdk/shared";
117
+ var subtitleStyle = z2.object({
118
+ size: z2.number().int().min(32).max(80).default(52),
119
+ position: z2.enum(["top", "middle", "bottom"]).default("bottom"),
120
+ color: z2.string().regex(/^#[0-9a-f]{6}$/i).default("#ffffff"),
121
+ background: z2.boolean().default(false)
122
+ }).strict();
123
+ var subtitleTrack = z2.object({ file: videoFileRef, style: subtitleStyle.default(() => subtitleStyle.parse({})) }).strict();
124
+
125
+ // packages/media-tools/src/shared.ts
126
+ var packageVersion = "0.1.22-ecommerce.20261110.1";
127
+ var Config = z3.object({
128
+ dataInstance: z3.string().min(1).default("user:data"),
129
+ studioInstance: z3.string().min(1).default("studio"),
130
+ executionNamespace: z3.string().regex(/^[a-zA-Z0-9_-]{1,64}$/).default("media"),
131
+ ffmpegPath: z3.string().min(1).default("ffmpeg"),
132
+ ffprobePath: z3.string().min(1).default("ffprobe")
133
+ }).strict();
134
+ var sourceInput = z3.object({ kind: z3.literal("source"), file: videoFileRef }).strict();
135
+ var editInput = z3.object({ kind: z3.literal("edit"), editRef: versionRef }).strict();
136
+ var videoInput = z3.discriminatedUnion("kind", [sourceInput, editInput]);
137
+ var sequenceVideoInput = z3.discriminatedUnion("kind", [
138
+ sourceInput.extend({ trimEndMs: z3.number().int().positive().optional() }),
124
139
  editInput
125
140
  ]);
126
- var colorAdjustment = z.object({
127
- brightness: z.number().finite().min(-0.5).max(0.5),
128
- contrast: z.number().finite().min(0).max(2),
129
- saturation: z.number().finite().min(0).max(2)
141
+ var colorAdjustment = z3.object({
142
+ brightness: z3.number().finite().min(-0.5).max(0.5),
143
+ contrast: z3.number().finite().min(0).max(2),
144
+ saturation: z3.number().finite().min(0).max(2)
130
145
  }).strict();
131
146
  var neutralColor = { brightness: 0, contrast: 1, saturation: 1 };
132
- var recipe = z.object({
133
- trim: z.object({ inMs: z.number().int().nonnegative(), outMs: z.number().int().positive() }).strict(),
134
- crop: z.object({
135
- x: z.number().finite().nonnegative(),
136
- y: z.number().finite().nonnegative(),
137
- width: z.number().finite().positive().max(1),
138
- height: z.number().finite().positive().max(1)
147
+ var recipe = z3.object({
148
+ trim: z3.object({ inMs: z3.number().int().nonnegative(), outMs: z3.number().int().positive() }).strict(),
149
+ crop: z3.object({
150
+ x: z3.number().finite().nonnegative(),
151
+ y: z3.number().finite().nonnegative(),
152
+ width: z3.number().finite().positive().max(1),
153
+ height: z3.number().finite().positive().max(1)
139
154
  }).strict(),
140
155
  color: colorAdjustment.optional(),
141
- speed: z.number().finite().min(0.25).max(4).optional()
156
+ speed: z3.number().finite().min(0.25).max(4).optional()
142
157
  }).strict().superRefine((v, c) => {
143
158
  if (v.trim.inMs >= v.trim.outMs)
144
159
  c.addIssue({ code: "custom", message: "The selected interval must have positive duration." });
@@ -154,62 +169,62 @@ var videoEditorTitles = {
154
169
  color: "Adjust Color",
155
170
  speed: "Video Speed"
156
171
  };
157
- var pixelRect = z.object({
158
- x: z.number().int().nonnegative(),
159
- y: z.number().int().nonnegative(),
160
- width: z.number().int().positive(),
161
- height: z.number().int().positive()
172
+ var pixelRect = z3.object({
173
+ x: z3.number().int().nonnegative(),
174
+ y: z3.number().int().nonnegative(),
175
+ width: z3.number().int().positive(),
176
+ height: z3.number().int().positive()
162
177
  }).strict();
163
- var geometry = z.object({
164
- displayWidth: z.number().int().positive(),
165
- displayHeight: z.number().int().positive(),
178
+ var geometry = z3.object({
179
+ displayWidth: z3.number().int().positive(),
180
+ displayHeight: z3.number().int().positive(),
166
181
  pixelRect
167
182
  }).strict();
168
- var metadata = z.object({
169
- durationMs: z.number().int().positive(),
170
- width: z.number().int().positive(),
171
- height: z.number().int().positive(),
172
- displayWidth: z.number().int().positive(),
173
- displayHeight: z.number().int().positive(),
174
- rotation: z.union([z.literal(0), z.literal(90), z.literal(180), z.literal(270)]),
175
- frameRate: z.number().positive().max(60),
176
- startTime: z.number().finite(),
177
- hasAudio: z.boolean(),
178
- audioSampleRate: z.number().int().nullable(),
179
- audioChannels: z.number().int().nullable(),
180
- audioStartTime: z.number().finite().nullable(),
181
- sizeBytes: z.number().int().nonnegative(),
182
- sha256: z.string().regex(/^[a-f0-9]{64}$/),
183
- colorInterpretation: z.enum(["declared-bt709", "assumed-bt709"]).optional()
183
+ var metadata = z3.object({
184
+ durationMs: z3.number().int().positive(),
185
+ width: z3.number().int().positive(),
186
+ height: z3.number().int().positive(),
187
+ displayWidth: z3.number().int().positive(),
188
+ displayHeight: z3.number().int().positive(),
189
+ rotation: z3.union([z3.literal(0), z3.literal(90), z3.literal(180), z3.literal(270)]),
190
+ frameRate: z3.number().positive().max(60),
191
+ startTime: z3.number().finite(),
192
+ hasAudio: z3.boolean(),
193
+ audioSampleRate: z3.number().int().nullable(),
194
+ audioChannels: z3.number().int().nullable(),
195
+ audioStartTime: z3.number().finite().nullable(),
196
+ sizeBytes: z3.number().int().nonnegative(),
197
+ sha256: z3.string().regex(/^[a-f0-9]{64}$/),
198
+ colorInterpretation: z3.enum(["declared-bt709", "assumed-bt709"]).optional()
184
199
  }).strict();
185
- var editDescriptor = z.object({ format: z.literal(1), file: videoFileRef, recipe, geometry, metadata }).strict();
186
- var saveEdit = z.object({
200
+ var editDescriptor = z3.object({ format: z3.literal(1), file: videoFileRef, recipe, geometry, metadata }).strict();
201
+ var saveEdit = z3.object({
187
202
  file: videoFileRef,
188
203
  recipe,
189
- editId: z.uuid().optional(),
190
- expectedRevision: z.number().int().positive().optional()
204
+ editId: z3.uuid().optional(),
205
+ expectedRevision: z3.number().int().positive().optional()
191
206
  }).strict().superRefine((v, c) => {
192
207
  if (Boolean(v.editId) !== Boolean(v.expectedRevision))
193
208
  c.addIssue({ code: "custom", message: "An edit update requires its revision." });
194
209
  });
195
- var outputName = z.string().trim().min(1).max(200);
196
- var gain = z.number().finite().min(-96).max(24);
197
- var milliseconds = z.number().int().min(0).max(6e5);
198
- var audioMix = z.object({
199
- version: z.literal(1),
210
+ var outputName = z3.string().trim().min(1).max(200);
211
+ var gain = z3.number().finite().min(-96).max(24);
212
+ var milliseconds = z3.number().int().min(0).max(6e5);
213
+ var audioMix = z3.object({
214
+ version: z3.literal(1),
200
215
  originalGainDb: gain.nullable().optional(),
201
- originals: z.array(
202
- z.object({
203
- inputIndex: z.number().int().min(0).max(63),
216
+ originals: z3.array(
217
+ z3.object({
218
+ inputIndex: z3.number().int().min(0).max(63),
204
219
  gainDb: gain.nullable(),
205
- role: z.enum(["dialogue", "ambience"]).optional()
220
+ role: z3.enum(["dialogue", "ambience"]).optional()
206
221
  }).strict()
207
222
  ).max(64).optional(),
208
- tracks: z.array(
209
- z.object({
210
- id: z.string().trim().min(1).max(128),
223
+ tracks: z3.array(
224
+ z3.object({
225
+ id: z3.string().trim().min(1).max(128),
211
226
  file: videoFileRef,
212
- role: z.enum(["narration", "music", "sfx"]),
227
+ role: z3.enum(["narration", "music", "sfx"]),
213
228
  atMs: milliseconds,
214
229
  inMs: milliseconds.optional(),
215
230
  outMs: milliseconds.optional(),
@@ -218,79 +233,80 @@ var audioMix = z.object({
218
233
  fadeOutMs: milliseconds.optional()
219
234
  }).strict()
220
235
  ).max(32),
221
- ducking: z.boolean().optional(),
222
- loudness: z.enum(["studio-web-v1", "off"]).optional()
236
+ ducking: z3.boolean().optional(),
237
+ loudness: z3.enum(["studio-web-v1", "off"]).optional()
223
238
  }).strict();
224
239
  var maxSequenceInputs = 64;
225
- var audioQuery = z.object({ inputs: z.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
240
+ var audioQuery = z3.object({ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
226
241
  var previewQuery = audioQuery.extend({
227
- knownRevision: z.number().int().nonnegative().optional()
242
+ knownRevision: z3.number().int().nonnegative().optional()
228
243
  });
229
- var audioPreviewResult = z.discriminatedUnion("state", [
230
- z.object({ state: z.literal("original"), revision: z.number() }),
231
- z.object({ state: z.literal("unchanged") }),
232
- z.object({ state: z.literal("preparing") }),
233
- z.object({
234
- state: z.literal("ready"),
235
- revision: z.number(),
244
+ var audioPreviewResult = z3.discriminatedUnion("state", [
245
+ z3.object({ state: z3.literal("original"), revision: z3.number() }),
246
+ z3.object({ state: z3.literal("unchanged") }),
247
+ z3.object({ state: z3.literal("preparing") }),
248
+ z3.object({
249
+ state: z3.literal("ready"),
250
+ revision: z3.number(),
236
251
  file: studioFileRef().nullable(),
237
- segments: z.array(z.object({ startMs: z.number(), durationMs: z.number().positive() }))
252
+ segments: z3.array(z3.object({ startMs: z3.number(), durationMs: z3.number().positive() }))
238
253
  })
239
254
  ]);
240
255
  var saveAudio = audioQuery.extend({
241
- expectedRevision: z.number().int().nonnegative(),
256
+ expectedRevision: z3.number().int().nonnegative(),
242
257
  mix: audioMix.nullable()
243
258
  });
244
- var remixRequest = z.object({
245
- basis: z.enum(["sources", "master"]),
259
+ var remixRequest = z3.object({
260
+ basis: z3.enum(["sources", "master"]),
246
261
  mix: audioMix,
247
- expectedAssetRevision: z.number().int().positive(),
248
- expectedMixRevision: z.number().int().nonnegative()
262
+ expectedAssetRevision: z3.number().int().positive(),
263
+ expectedMixRevision: z3.number().int().nonnegative()
249
264
  }).strict();
250
- var processVideo = z.object({
265
+ var processVideo = z3.object({
251
266
  input: videoInput,
252
267
  outputName,
253
- retryOfJobId: z.uuid().optional(),
268
+ retryOfJobId: z3.uuid().optional(),
254
269
  remix: remixRequest.optional()
255
270
  }).strict().refine((v) => !v.remix || v.input.kind === "source", "Remix requires a fixed source file.");
256
- var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.number().int().min(2).max(3840) }).strict().refine(
271
+ var canvas = z3.object({ width: z3.number().int().min(2).max(3840), height: z3.number().int().min(2).max(3840) }).strict().refine(
257
272
  (v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
258
273
  "Canvas dimensions must be even and within 3840 by 2160."
259
274
  );
260
- var exportFormat = z.enum(
275
+ var exportFormat = z3.enum(
261
276
  Object.keys(exportProfiles)
262
277
  );
263
- var exportSettings = z.object({
278
+ var exportSettings = z3.object({
264
279
  format: exportFormat,
265
- aspect: z.enum(exportAspects),
266
- resolution: z.union([
267
- z.literal("source"),
268
- z.literal(480),
269
- z.literal(720),
270
- z.literal(1080),
271
- z.literal(2160)
280
+ aspect: z3.enum(exportAspects),
281
+ resolution: z3.union([
282
+ z3.literal("source"),
283
+ z3.literal(480),
284
+ z3.literal(720),
285
+ z3.literal(1080),
286
+ z3.literal(2160)
272
287
  ]),
273
- frameRate: z.union([
274
- z.literal("source"),
275
- z.literal(24),
276
- z.literal(25),
277
- z.literal(30),
278
- z.literal(50),
279
- z.literal(60)
288
+ frameRate: z3.union([
289
+ z3.literal("source"),
290
+ z3.literal(24),
291
+ z3.literal(25),
292
+ z3.literal(30),
293
+ z3.literal(50),
294
+ z3.literal(60)
280
295
  ]),
281
- quality: z.enum(exportQualities),
282
- audio: z.boolean()
296
+ quality: z3.enum(exportQualities),
297
+ audio: z3.boolean()
283
298
  }).strict();
284
- var processSequence = z.object({
285
- inputs: z.array(sequenceVideoInput).min(1).max(maxSequenceInputs),
299
+ var processSequence = z3.object({
300
+ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs),
286
301
  outputName,
287
302
  canvas,
303
+ subtitle: subtitleTrack.optional(),
288
304
  settings: exportSettings.optional(),
289
- retryOfJobId: z.uuid().optional()
305
+ retryOfJobId: z3.uuid().optional()
290
306
  }).strict();
291
- var mediaRequest = z.discriminatedUnion("operation", [
292
- z.object({ operation: z.literal("video.process"), input: processVideo }).strict(),
293
- z.object({ operation: z.literal("sequence.process"), input: processSequence }).strict()
307
+ var mediaRequest = z3.discriminatedUnion("operation", [
308
+ z3.object({ operation: z3.literal("video.process"), input: processVideo }).strict(),
309
+ z3.object({ operation: z3.literal("sequence.process"), input: processSequence }).strict()
294
310
  ]);
295
311
  var jobStates = [
296
312
  "queued",
@@ -301,13 +317,13 @@ var jobStates = [
301
317
  "canceled",
302
318
  "interrupted"
303
319
  ];
304
- var jobsQuery = z.object({
305
- limit: z.number().int().min(1).max(100).default(50),
306
- offset: z.number().int().nonnegative().default(0),
307
- request: z.object({
308
- operation: z.enum(["video.process", "sequence.process"]),
309
- requestKey: z.string().min(1).max(128),
310
- intent: z.union([processVideo, processSequence])
320
+ var jobsQuery = z3.object({
321
+ limit: z3.number().int().min(1).max(100).default(50),
322
+ offset: z3.number().int().nonnegative().default(0),
323
+ request: z3.object({
324
+ operation: z3.enum(["video.process", "sequence.process"]),
325
+ requestKey: z3.string().min(1).max(128),
326
+ intent: z3.union([processVideo, processSequence])
311
327
  }).strict().optional()
312
328
  }).strict();
313
329
  function mediaError(code, message) {
@@ -432,6 +448,8 @@ export {
432
448
  saveAudio,
433
449
  saveEdit,
434
450
  sequenceVideoInput,
451
+ subtitleStyle,
452
+ subtitleTrack,
435
453
  versionRef,
436
454
  videoEditorTitles,
437
455
  videoFileRef,
Binary file
@@ -0,0 +1,46 @@
1
+ import { z } from 'vivix-studio/sdk/shared';
2
+
3
+ declare const subtitleStyle: z.ZodObject<{
4
+ size: z.ZodDefault<z.ZodNumber>;
5
+ position: z.ZodDefault<z.ZodEnum<{
6
+ top: "top";
7
+ middle: "middle";
8
+ bottom: "bottom";
9
+ }>>;
10
+ color: z.ZodDefault<z.ZodString>;
11
+ background: z.ZodDefault<z.ZodBoolean>;
12
+ }, z.core.$strict>;
13
+ declare const subtitleTrack: z.ZodObject<{
14
+ file: z.ZodObject<{
15
+ source: z.ZodObject<{
16
+ storeId: z.ZodUUID;
17
+ objectId: z.ZodUUID;
18
+ versionId: z.ZodUUID;
19
+ }, z.core.$strict>;
20
+ fileId: z.ZodUUID;
21
+ }, z.core.$strict>;
22
+ style: z.ZodDefault<z.ZodObject<{
23
+ size: z.ZodDefault<z.ZodNumber>;
24
+ position: z.ZodDefault<z.ZodEnum<{
25
+ top: "top";
26
+ middle: "middle";
27
+ bottom: "bottom";
28
+ }>>;
29
+ color: z.ZodDefault<z.ZodString>;
30
+ background: z.ZodDefault<z.ZodBoolean>;
31
+ }, z.core.$strict>>;
32
+ }, z.core.$strict>;
33
+ type SubtitleTrack = z.infer<typeof subtitleTrack>;
34
+ interface SubtitlePreview {
35
+ width: number;
36
+ height: number;
37
+ top: number;
38
+ band: number;
39
+ cues: {
40
+ start: number;
41
+ end: number;
42
+ image: string;
43
+ }[];
44
+ }
45
+
46
+ export { type SubtitlePreview, type SubtitleTrack, subtitleStyle, subtitleTrack };
@@ -0,0 +1,20 @@
1
+ // packages/media-tools/src/subtitle-track.ts
2
+ import { z as z2 } from "vivix-studio/sdk/shared";
3
+
4
+ // packages/media-tools/src/file-ref.ts
5
+ import { z } from "vivix-studio/sdk/shared";
6
+ var versionRef = z.object({ storeId: z.uuid(), objectId: z.uuid(), versionId: z.uuid() }).strict();
7
+ var videoFileRef = z.object({ source: versionRef, fileId: z.uuid() }).strict();
8
+
9
+ // packages/media-tools/src/subtitle-track.ts
10
+ var subtitleStyle = z2.object({
11
+ size: z2.number().int().min(32).max(80).default(52),
12
+ position: z2.enum(["top", "middle", "bottom"]).default("bottom"),
13
+ color: z2.string().regex(/^#[0-9a-f]{6}$/i).default("#ffffff"),
14
+ background: z2.boolean().default(false)
15
+ }).strict();
16
+ var subtitleTrack = z2.object({ file: videoFileRef, style: subtitleStyle.default(() => subtitleStyle.parse({})) }).strict();
17
+ export {
18
+ subtitleStyle,
19
+ subtitleTrack
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/media-tools",
3
- "version": "1.0.0-beta.21",
3
+ "version": "1.0.0-beta.22",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -12,7 +12,8 @@
12
12
  "dist",
13
13
  "studio-plugin.json",
14
14
  "README.md",
15
- "docs"
15
+ "docs",
16
+ "resources"
16
17
  ],
17
18
  "engines": {
18
19
  "node": ">=22.12.0"
@@ -30,6 +31,10 @@
30
31
  "./client": {
31
32
  "types": "./dist/client.d.ts",
32
33
  "import": "./dist/client.js"
34
+ },
35
+ "./subtitle-track": {
36
+ "types": "./dist/subtitle-track.d.ts",
37
+ "import": "./dist/subtitle-track.js"
33
38
  }
34
39
  },
35
40
  "peerDependencies": {
@@ -38,7 +43,10 @@
38
43
  "react-dom": "^19.0.0"
39
44
  },
40
45
  "devDependencies": {
41
- "@vivix-labs/ui-system": "workspace:*"
46
+ "@resvg/resvg-wasm": "2.6.2",
47
+ "@types/opentype.js": "^1.3.10",
48
+ "@vivix-labs/ui-system": "workspace:*",
49
+ "opentype.js": "1.3.4"
42
50
  },
43
51
  "scripts": {
44
52
  "build": "node ../../scripts/build-product-packages.mjs media-tools"