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

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.
Files changed (60) hide show
  1. package/README.md +38 -12
  2. package/dist/assets/1-1-WUUPNDJP.svg +7 -0
  3. package/dist/assets/16-9-BAFQTZK7.svg +9 -0
  4. package/dist/assets/2-3-WPG3UQBV.svg +7 -0
  5. package/dist/assets/3-2-YZTSUZ37.svg +7 -0
  6. package/dist/assets/3-4-7YROL4JU.svg +7 -0
  7. package/dist/assets/4-3-YG4LTLGD.svg +7 -0
  8. package/dist/assets/9-16-CYXX6QAR.svg +9 -0
  9. package/dist/assets/add-circle-RPMXNTWW.svg +4 -0
  10. package/dist/assets/captions-16-55I6JRWY.svg +5 -0
  11. package/dist/assets/captions-24-4YNDEZZX.svg +5 -0
  12. package/dist/assets/chevrons-up-down-KDZMS6DI.svg +3 -0
  13. package/dist/assets/collapse-diagonal-16-2IRQGCLB.svg +6 -0
  14. package/dist/assets/collapse-diagonal-24-GHD6Z54K.svg +6 -0
  15. package/dist/assets/copy-document-EF4PHM7F.svg +10 -0
  16. package/dist/assets/crop-5JXWHIPN.svg +6 -0
  17. package/dist/assets/delete-4Y3OUMEL.svg +8 -0
  18. package/dist/assets/download-16-QVS2YNPN.svg +4 -0
  19. package/dist/assets/download-24-ARCWU2MF.svg +4 -0
  20. package/dist/assets/download-VTKCEAZG.svg +6 -0
  21. package/dist/assets/expand-diagonal-16-QUIZSPJN.svg +10 -0
  22. package/dist/assets/expand-diagonal-24-XPK72ILY.svg +10 -0
  23. package/dist/assets/favorite-6GMNHJCN.svg +5 -0
  24. package/dist/assets/favorite-filled-FR74TEBM.svg +3 -0
  25. package/dist/assets/filter-JSDZZVGN.svg +5 -0
  26. package/dist/assets/freeform-E5MLUKDE.svg +18 -0
  27. package/dist/assets/fullscreen-exit-ADYOPBYH.svg +3 -0
  28. package/dist/assets/grid-16-POIO22HZ.svg +6 -0
  29. package/dist/assets/grid-24-U6IRT56K.svg +6 -0
  30. package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
  31. package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
  32. package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
  33. package/dist/assets/list-16-YAVTLHXZ.svg +8 -0
  34. package/dist/assets/list-24-O6WDB6WJ.svg +8 -0
  35. package/dist/assets/original-LBKLUQVV.svg +18 -0
  36. package/dist/assets/pause-16-444PD7SY.svg +4 -0
  37. package/dist/assets/pause-24-WQXRNLW3.svg +4 -0
  38. package/dist/assets/play-16-5B2LZITW.svg +3 -0
  39. package/dist/assets/play-24-3IPXXAC4.svg +3 -0
  40. package/dist/assets/refresh-WQ3CTB57.svg +3 -0
  41. package/dist/assets/replace-PJXDOQDX.svg +3 -0
  42. package/dist/assets/{search-JUOSGQRM.svg → search-FMYQZJWA.svg} +1 -1
  43. package/dist/assets/select-items-GJZIVO37.svg +6 -0
  44. package/dist/assets/trim-LQMHHN2M.svg +9 -0
  45. package/dist/assets/upload-U5RZT5QI.svg +5 -0
  46. package/dist/assets/volume-16-ENYWJAGG.svg +5 -0
  47. package/dist/assets/volume-24-MVQ6CAXW.svg +5 -0
  48. package/dist/assets/volume-off-16-ALKG7632.svg +4 -0
  49. package/dist/assets/volume-off-24-2R4VED3N.svg +4 -0
  50. package/dist/client.bundle.js +1517 -262
  51. package/dist/client.css +2368 -181
  52. package/dist/server.d.ts +2 -1
  53. package/dist/server.js +1463 -259
  54. package/dist/shared.d.ts +513 -3
  55. package/dist/shared.js +230 -7
  56. package/{skills/SKILL.md → docs/operations.md} +7 -7
  57. package/package.json +5 -4
  58. package/studio-plugin.json +2 -5
  59. package/dist/assets/player-cover-shade-LLH6KOCQ.png +0 -0
  60. /package/{skills/references → docs}/processing.md +0 -0
package/dist/shared.js CHANGED
@@ -1,5 +1,111 @@
1
+ // packages/media-tools/src/watch-sequence-sound.ts
2
+ function watchSequenceSound(client, instanceId, getInputs, update) {
3
+ const abort = new AbortController();
4
+ let inputs, revision, url;
5
+ let timer, running = false;
6
+ const release = () => {
7
+ if (url) URL.revokeObjectURL(url);
8
+ url = void 0;
9
+ };
10
+ async function refresh() {
11
+ clearTimeout(timer);
12
+ if (running || abort.signal.aborted) return;
13
+ running = true;
14
+ let delay = 4e3;
15
+ try {
16
+ inputs ??= await getInputs();
17
+ if (abort.signal.aborted) return;
18
+ const result = await client.invoke(
19
+ { instanceId, operationId: "sequence.audio.preview" },
20
+ { inputs, ...revision !== void 0 && { knownRevision: revision } }
21
+ );
22
+ if (abort.signal.aborted) return;
23
+ if (result.state === "preparing") {
24
+ release();
25
+ delay = 600;
26
+ update({ state: "loading" });
27
+ } else if (result.state === "original") {
28
+ release();
29
+ revision = result.revision;
30
+ update({ state: "original" });
31
+ } else if (result.state === "ready") {
32
+ let blob;
33
+ if (result.file) {
34
+ const response = await fetch(client.transfers.forInstance(instanceId).url(result.file), {
35
+ signal: abort.signal
36
+ });
37
+ if (!response.ok) throw Error("Could not load the mixed audio preview.");
38
+ blob = await response.blob();
39
+ }
40
+ if (abort.signal.aborted) return;
41
+ release();
42
+ url = blob && URL.createObjectURL(blob);
43
+ revision = result.revision;
44
+ update({ state: "mixed", ...url && { url }, segments: result.segments });
45
+ }
46
+ } catch (error) {
47
+ if (!abort.signal.aborted) {
48
+ revision = void 0;
49
+ update({
50
+ state: "error",
51
+ message: error instanceof Error ? error.message : "Could not load the mixed audio preview."
52
+ });
53
+ }
54
+ } finally {
55
+ running = false;
56
+ if (!abort.signal.aborted && !document.hidden) timer = setTimeout(refresh, delay);
57
+ }
58
+ }
59
+ const visible = () => {
60
+ if (!document.hidden) void refresh();
61
+ };
62
+ document.addEventListener("visibilitychange", visible);
63
+ window.addEventListener("focus", visible);
64
+ void refresh();
65
+ return () => {
66
+ abort.abort();
67
+ clearTimeout(timer);
68
+ release();
69
+ document.removeEventListener("visibilitychange", visible);
70
+ window.removeEventListener("focus", visible);
71
+ };
72
+ }
73
+
74
+ // packages/media-tools/src/export-settings.ts
75
+ var exportProfiles = {
76
+ h264: {
77
+ label: "MP4 \xB7 H.264",
78
+ extension: "mp4",
79
+ container: "mp4",
80
+ codec: "h264",
81
+ encoder: "libx264",
82
+ audio: "aac",
83
+ crf: [18, 23, 28]
84
+ },
85
+ hevc: {
86
+ label: "MP4 \xB7 H.265",
87
+ extension: "mp4",
88
+ container: "mp4",
89
+ codec: "hevc",
90
+ encoder: "libx265",
91
+ audio: "aac",
92
+ crf: [20, 25, 30]
93
+ },
94
+ vp9: {
95
+ label: "WebM \xB7 VP9",
96
+ extension: "webm",
97
+ container: "webm",
98
+ codec: "vp9",
99
+ encoder: "libvpx-vp9",
100
+ audio: "opus",
101
+ crf: [23, 31, 39]
102
+ }
103
+ };
104
+ var exportAspects = ["source", "16:9", "9:16", "1:1", "4:3", "3:4", "21:9"];
105
+ var exportQualities = ["high", "standard", "small"];
106
+
1
107
  // packages/media-tools/src/shared.ts
2
- import { z, PluginError } from "vivix-studio/sdk/shared";
108
+ import { z, PluginError, studioFileRef } from "vivix-studio/sdk/shared";
3
109
  var packageVersion = "0.1.22-ecommerce.20261110.1";
4
110
  var Config = z.object({
5
111
  dataInstance: z.string().min(1).default("user:data"),
@@ -17,6 +123,12 @@ var sequenceVideoInput = z.discriminatedUnion("kind", [
17
123
  sourceInput.extend({ trimEndMs: z.number().int().positive().optional() }),
18
124
  editInput
19
125
  ]);
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)
130
+ }).strict();
131
+ var neutralColor = { brightness: 0, contrast: 1, saturation: 1 };
20
132
  var recipe = z.object({
21
133
  trim: z.object({ inMs: z.number().int().nonnegative(), outMs: z.number().int().positive() }).strict(),
22
134
  crop: z.object({
@@ -24,13 +136,24 @@ var recipe = z.object({
24
136
  y: z.number().finite().nonnegative(),
25
137
  width: z.number().finite().positive().max(1),
26
138
  height: z.number().finite().positive().max(1)
27
- }).strict()
139
+ }).strict(),
140
+ color: colorAdjustment.optional(),
141
+ speed: z.number().finite().min(0.25).max(4).optional()
28
142
  }).strict().superRefine((v, c) => {
29
143
  if (v.trim.inMs >= v.trim.outMs)
30
144
  c.addIssue({ code: "custom", message: "The selected interval must have positive duration." });
31
145
  if (v.crop.x + v.crop.width > 1 + 1e-9 || v.crop.y + v.crop.height > 1 + 1e-9)
32
146
  c.addIssue({ code: "custom", message: "The crop must remain inside the source picture." });
33
147
  });
148
+ function recipeDurationMs(value) {
149
+ return Math.max(1, Math.round((value.trim.outMs - value.trim.inMs) / (value.speed ?? 1)));
150
+ }
151
+ var videoEditorTitles = {
152
+ crop: "Crop Video",
153
+ trim: "Trim Video",
154
+ color: "Adjust Color",
155
+ speed: "Video Speed"
156
+ };
34
157
  var pixelRect = z.object({
35
158
  x: z.number().int().nonnegative(),
36
159
  y: z.number().int().nonnegative(),
@@ -70,15 +193,99 @@ var saveEdit = z.object({
70
193
  c.addIssue({ code: "custom", message: "An edit update requires its revision." });
71
194
  });
72
195
  var outputName = z.string().trim().min(1).max(200);
73
- var processVideo = z.object({ input: videoInput, outputName, retryOfJobId: z.uuid().optional() }).strict();
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),
200
+ originalGainDb: gain.nullable().optional(),
201
+ originals: z.array(
202
+ z.object({
203
+ inputIndex: z.number().int().min(0).max(63),
204
+ gainDb: gain.nullable(),
205
+ role: z.enum(["dialogue", "ambience"]).optional()
206
+ }).strict()
207
+ ).max(64).optional(),
208
+ tracks: z.array(
209
+ z.object({
210
+ id: z.string().trim().min(1).max(128),
211
+ file: videoFileRef,
212
+ role: z.enum(["narration", "music", "sfx"]),
213
+ atMs: milliseconds,
214
+ inMs: milliseconds.optional(),
215
+ outMs: milliseconds.optional(),
216
+ gainDb: gain.optional(),
217
+ fadeInMs: milliseconds.optional(),
218
+ fadeOutMs: milliseconds.optional()
219
+ }).strict()
220
+ ).max(32),
221
+ ducking: z.boolean().optional(),
222
+ loudness: z.enum(["studio-web-v1", "off"]).optional()
223
+ }).strict();
224
+ var maxSequenceInputs = 64;
225
+ var audioQuery = z.object({ inputs: z.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
226
+ var previewQuery = audioQuery.extend({
227
+ knownRevision: z.number().int().nonnegative().optional()
228
+ });
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(),
236
+ file: studioFileRef().nullable(),
237
+ segments: z.array(z.object({ startMs: z.number(), durationMs: z.number().positive() }))
238
+ })
239
+ ]);
240
+ var saveAudio = audioQuery.extend({
241
+ expectedRevision: z.number().int().nonnegative(),
242
+ mix: audioMix.nullable()
243
+ });
244
+ var remixRequest = z.object({
245
+ basis: z.enum(["sources", "master"]),
246
+ mix: audioMix,
247
+ expectedAssetRevision: z.number().int().positive(),
248
+ expectedMixRevision: z.number().int().nonnegative()
249
+ }).strict();
250
+ var processVideo = z.object({
251
+ input: videoInput,
252
+ outputName,
253
+ retryOfJobId: z.uuid().optional(),
254
+ remix: remixRequest.optional()
255
+ }).strict().refine((v) => !v.remix || v.input.kind === "source", "Remix requires a fixed source file.");
74
256
  var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.number().int().min(2).max(3840) }).strict().refine(
75
257
  (v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
76
258
  "Canvas dimensions must be even and within 3840 by 2160."
77
259
  );
260
+ var exportFormat = z.enum(
261
+ Object.keys(exportProfiles)
262
+ );
263
+ var exportSettings = z.object({
264
+ 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)
272
+ ]),
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)
280
+ ]),
281
+ quality: z.enum(exportQualities),
282
+ audio: z.boolean()
283
+ }).strict();
78
284
  var processSequence = z.object({
79
- inputs: z.array(sequenceVideoInput).min(1).max(64),
285
+ inputs: z.array(sequenceVideoInput).min(1).max(maxSequenceInputs),
80
286
  outputName,
81
287
  canvas,
288
+ settings: exportSettings.optional(),
82
289
  retryOfJobId: z.uuid().optional()
83
290
  }).strict();
84
291
  var mediaRequest = z.discriminatedUnion("operation", [
@@ -132,7 +339,9 @@ function normalizeRecipe(raw, displayWidth, displayHeight, durationMs) {
132
339
  y: y / displayHeight,
133
340
  width: pixelRect2.width / displayWidth,
134
341
  height: pixelRect2.height / displayHeight
135
- }
342
+ },
343
+ ...value.color ? { color: { ...value.color } } : {},
344
+ ...value.speed === void 0 ? {} : { speed: value.speed }
136
345
  },
137
346
  geometry: { displayWidth, displayHeight, pixelRect: pixelRect2 }
138
347
  };
@@ -190,28 +399,42 @@ function readSavedEdit(data, raw) {
190
399
  file: value.file,
191
400
  recipe: value.recipe,
192
401
  geometry: value.geometry,
193
- effectiveDurationMs: value.recipe.trim.outMs - value.recipe.trim.inMs
402
+ effectiveDurationMs: recipeDurationMs(value.recipe)
194
403
  };
195
404
  }
196
405
  export {
197
406
  Config,
407
+ audioMix,
408
+ audioPreviewResult,
409
+ audioQuery,
198
410
  canvas,
411
+ colorAdjustment,
199
412
  editDescriptor,
413
+ exportFormat,
414
+ exportSettings,
200
415
  geometry,
201
416
  jobStates,
202
417
  jobsQuery,
418
+ maxSequenceInputs,
203
419
  mediaError,
204
420
  mediaRequest,
205
421
  metadata,
422
+ neutralColor,
206
423
  normalizeRecipe,
207
424
  packageVersion,
425
+ previewQuery,
208
426
  processSequence,
209
427
  processVideo,
210
428
  readSavedEdit,
211
429
  recipe,
430
+ recipeDurationMs,
212
431
  sameFile,
432
+ saveAudio,
213
433
  saveEdit,
434
+ sequenceVideoInput,
214
435
  versionRef,
436
+ videoEditorTitles,
215
437
  videoFileRef,
216
- videoInput
438
+ videoInput,
439
+ watchSequenceSound
217
440
  };
@@ -1,12 +1,7 @@
1
- ---
2
- name: vivix-media-tools
3
- description: Trim or crop fixed Studio video versions, compare candidates, and process or export video through the installed media-tools queue. Use for saved edit recipes, actual edited previews, sequence exports, and original-job recovery. Selection and storyboards remain with the calling project/workbench.
4
- ---
5
-
6
1
  # Edit, compare, and export Studio video
7
2
 
8
3
  Discover the configured media instance through `plugin list` and `plugin describe`
9
- for the actual project. Read the workspace Skill returned by `agent guide --json`
4
+ for the actual project. Read the unified `vivix-studio` Skill
10
5
  for page opening and chat presentation. Resolve exact saved source versions through
11
6
  the calling project's operations. Instance IDs and candidate order are caller data.
12
7
 
@@ -17,6 +12,11 @@ range and preserves an existing crop unless the user asks to change it. A Crop
17
12
  request changes framing and preserves the existing time range. For "the first
18
13
  8 seconds", use `[0,8000)` milliseconds when the source is long enough.
19
14
 
15
+ Color adjusts `recipe.color` (brightness -0.5–0.5, contrast 0–2, saturation 0–2).
16
+ Speed adjusts `recipe.speed` (0.25–4×), including pitch-preserving audio. Preserve
17
+ the other recipe fields. Missing color and speed fields mean unchanged colors and
18
+ 1× playback. Browser color preview is approximate; verify the processed output.
19
+
20
20
  `edits.save` saves an immutable recipe; it does not encode a video or select a
21
21
  candidate. Bind the returned edit through the caller's operation with its observed
22
22
  revisions. A conflict retains the draft and saved edit. Reconcile the intended
@@ -25,7 +25,7 @@ source and current selection before another bind.
25
25
  To deliver a playable edited result, use `video.process` or the caller's whole-film
26
26
  export through `sequence.process`. Read the exact input/output schema. Save the
27
27
  original intent and key, follow the accepted durable job, and present only its
28
- actual succeeded result. Read [processing and recovery](references/processing.md)
28
+ actual succeeded result. Read [processing and recovery](processing.md)
29
29
  for format, aspect, queue, cancellation, and uncertain-response details.
30
30
 
31
31
  ## Compare
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/media-tools",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.21",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -11,7 +11,8 @@
11
11
  "files": [
12
12
  "dist",
13
13
  "studio-plugin.json",
14
- "skills"
14
+ "README.md",
15
+ "docs"
15
16
  ],
16
17
  "engines": {
17
18
  "node": ">=22.12.0"
@@ -37,9 +38,9 @@
37
38
  "react-dom": "^19.0.0"
38
39
  },
39
40
  "devDependencies": {
40
- "@vivix-labs/ui-system": "1.0.0-beta.2"
41
+ "@vivix-labs/ui-system": "workspace:*"
41
42
  },
42
43
  "scripts": {
43
44
  "build": "node ../../scripts/build-product-packages.mjs media-tools"
44
45
  }
45
- }
46
+ }
@@ -2,10 +2,7 @@
2
2
  "manifestVersion": "0.2",
3
3
  "id": "media-tools",
4
4
  "requirements": {
5
- "studioPluginApi": "0.2.0"
5
+ "studioPluginApi": "^0.2.7"
6
6
  },
7
- "requestedAccess": [],
8
- "resources": {
9
- "skills": ["skills/SKILL.md"]
10
- }
7
+ "requestedAccess": []
11
8
  }
File without changes