@vivix-labs/media-tools 1.0.0-beta.23 → 1.0.0-beta.24
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/client.bundle.js +8 -7
- package/dist/client.css +10 -0
- package/dist/server.js +326 -67
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +6 -5
- package/dist/worker.js +33 -0
- package/package.json +2 -1
package/dist/client.bundle.js
CHANGED
|
@@ -81,6 +81,8 @@ var sequenceVideoInput = z3.discriminatedUnion("kind", [
|
|
|
81
81
|
sourceInput.extend({ trimEndMs: z3.number().int().positive().optional() }),
|
|
82
82
|
editInput
|
|
83
83
|
]);
|
|
84
|
+
var maxSequenceInputs = 64;
|
|
85
|
+
var sequenceInputs = z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs);
|
|
84
86
|
var colorAdjustment = z3.object({
|
|
85
87
|
brightness: z3.number().finite().min(-0.5).max(0.5),
|
|
86
88
|
contrast: z3.number().finite().min(0).max(2),
|
|
@@ -158,11 +160,11 @@ var audioMix = z3.object({
|
|
|
158
160
|
originalGainDb: gain.nullable().optional(),
|
|
159
161
|
originals: z3.array(
|
|
160
162
|
z3.object({
|
|
161
|
-
inputIndex: z3.number().int().min(0).max(
|
|
163
|
+
inputIndex: z3.number().int().min(0).max(maxSequenceInputs - 1),
|
|
162
164
|
gainDb: gain.nullable(),
|
|
163
165
|
role: z3.enum(["dialogue", "ambience"]).optional()
|
|
164
166
|
}).strict()
|
|
165
|
-
).max(
|
|
167
|
+
).max(maxSequenceInputs).optional(),
|
|
166
168
|
tracks: z3.array(
|
|
167
169
|
z3.object({
|
|
168
170
|
id: z3.string().trim().min(1).max(128),
|
|
@@ -179,8 +181,7 @@ var audioMix = z3.object({
|
|
|
179
181
|
ducking: z3.boolean().optional(),
|
|
180
182
|
loudness: z3.enum(["studio-web-v1", "off"]).optional()
|
|
181
183
|
}).strict();
|
|
182
|
-
var
|
|
183
|
-
var audioQuery = z3.object({ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
|
|
184
|
+
var audioQuery = z3.object({ inputs: sequenceInputs }).strict();
|
|
184
185
|
var previewQuery = audioQuery.extend({
|
|
185
186
|
knownRevision: z3.number().int().nonnegative().optional()
|
|
186
187
|
});
|
|
@@ -240,7 +241,7 @@ var exportSettings = z3.object({
|
|
|
240
241
|
audio: z3.boolean()
|
|
241
242
|
}).strict();
|
|
242
243
|
var processSequence = z3.object({
|
|
243
|
-
inputs:
|
|
244
|
+
inputs: sequenceInputs,
|
|
244
245
|
outputName,
|
|
245
246
|
canvas,
|
|
246
247
|
subtitle: subtitleTrack.optional(),
|
|
@@ -1322,9 +1323,9 @@ function timeLabel2(seconds, padMinutes = false) {
|
|
|
1322
1323
|
const minutes = String(Math.floor(whole / 60));
|
|
1323
1324
|
return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
|
|
1324
1325
|
}
|
|
1325
|
-
function PlaybackControls({ playing, muted, time, duration, size = "medium", variant = "default", iconSet, singleVideo = false, disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreen = false, fullscreenLabel = fullscreen ? "Exit fullscreen" : "Enter fullscreen", actions, appearance = "on-content", timeDisplay = "combined", renderTimeline }) {
|
|
1326
|
+
function PlaybackControls({ playing, muted, time, duration, size = "medium", variant = "default", iconSet, singleVideo = false, disabled, seekDisabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreen = false, fullscreenLabel = fullscreen ? "Exit fullscreen" : "Enter fullscreen", actions, appearance = "on-content", timeDisplay = "combined", renderTimeline }) {
|
|
1326
1327
|
const resolvedIconSet = iconSet ?? (variant === "chat" ? "chat" : "workbench");
|
|
1327
|
-
const slider = _jsx12("input", { className: "vx-playback-range", "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) });
|
|
1328
|
+
const slider = _jsx12("input", { className: "vx-playback-range", "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || seekDisabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) });
|
|
1328
1329
|
return _jsxs11("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-variant": variant === "chat" ? "chat" : void 0, "data-icon-set": resolvedIconSet === "chat" ? "chat" : void 0, "data-single-video": singleVideo || void 0, "data-appearance": appearance, "data-time-display": timeDisplay, style: {
|
|
1329
1330
|
"--vx-playback-fraction": duration > 0 ? Math.min(1, Math.max(0, time / duration)) : 0
|
|
1330
1331
|
}, children: [_jsx12(IconButton, { variant: size === "small" ? "icon-bare-xs" : "icon-ghost-sm", icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx12("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel2(time, true) }), renderTimeline ? renderTimeline(slider) : slider, _jsx12("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel2(duration, true) : `${timeLabel2(time)} / ${timeLabel2(duration)}` }), _jsx12(IconButton, { variant: size === "small" ? "icon-bare-xs" : "icon-ghost-sm", icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx12(IconButton, { variant: size === "small" ? "icon-bare-xs" : "icon-ghost-sm", icon: fullscreen ? "fullscreen-exit" : size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, "aria-pressed": fullscreen, onClick: onFullscreen })] });
|
package/dist/client.css
CHANGED
|
@@ -1968,6 +1968,16 @@
|
|
|
1968
1968
|
margin: 0;
|
|
1969
1969
|
color: var(--vx-text-secondary-readable);
|
|
1970
1970
|
}
|
|
1971
|
+
.vx-audio-preview[data-variant=timeline] {
|
|
1972
|
+
display: grid;
|
|
1973
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1974
|
+
gap: var(--vx-space-4);
|
|
1975
|
+
padding: var(--vx-space-8);
|
|
1976
|
+
background: var(--vx-surface-input);
|
|
1977
|
+
}
|
|
1978
|
+
.vx-audio-preview[data-variant=timeline] > .vx-audio-caption > span {
|
|
1979
|
+
font: var(--vx-typography-inter-14-semi-bold);
|
|
1980
|
+
}
|
|
1971
1981
|
.vx-audio-preview[data-variant=compact] {
|
|
1972
1982
|
width: min(100%, 290px);
|
|
1973
1983
|
min-width: 0;
|
package/dist/server.js
CHANGED
|
@@ -89,6 +89,8 @@ var sequenceVideoInput = z3.discriminatedUnion("kind", [
|
|
|
89
89
|
sourceInput.extend({ trimEndMs: z3.number().int().positive().optional() }),
|
|
90
90
|
editInput
|
|
91
91
|
]);
|
|
92
|
+
var maxSequenceInputs = 64;
|
|
93
|
+
var sequenceInputs = z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs);
|
|
92
94
|
var colorAdjustment = z3.object({
|
|
93
95
|
brightness: z3.number().finite().min(-0.5).max(0.5),
|
|
94
96
|
contrast: z3.number().finite().min(0).max(2),
|
|
@@ -159,11 +161,11 @@ var audioMix = z3.object({
|
|
|
159
161
|
originalGainDb: gain.nullable().optional(),
|
|
160
162
|
originals: z3.array(
|
|
161
163
|
z3.object({
|
|
162
|
-
inputIndex: z3.number().int().min(0).max(
|
|
164
|
+
inputIndex: z3.number().int().min(0).max(maxSequenceInputs - 1),
|
|
163
165
|
gainDb: gain.nullable(),
|
|
164
166
|
role: z3.enum(["dialogue", "ambience"]).optional()
|
|
165
167
|
}).strict()
|
|
166
|
-
).max(
|
|
168
|
+
).max(maxSequenceInputs).optional(),
|
|
167
169
|
tracks: z3.array(
|
|
168
170
|
z3.object({
|
|
169
171
|
id: z3.string().trim().min(1).max(128),
|
|
@@ -180,8 +182,7 @@ var audioMix = z3.object({
|
|
|
180
182
|
ducking: z3.boolean().optional(),
|
|
181
183
|
loudness: z3.enum(["studio-web-v1", "off"]).optional()
|
|
182
184
|
}).strict();
|
|
183
|
-
var
|
|
184
|
-
var audioQuery = z3.object({ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
|
|
185
|
+
var audioQuery = z3.object({ inputs: sequenceInputs }).strict();
|
|
185
186
|
var previewQuery = audioQuery.extend({
|
|
186
187
|
knownRevision: z3.number().int().nonnegative().optional()
|
|
187
188
|
});
|
|
@@ -241,7 +242,7 @@ var exportSettings = z3.object({
|
|
|
241
242
|
audio: z3.boolean()
|
|
242
243
|
}).strict();
|
|
243
244
|
var processSequence = z3.object({
|
|
244
|
-
inputs:
|
|
245
|
+
inputs: sequenceInputs,
|
|
245
246
|
outputName,
|
|
246
247
|
canvas,
|
|
247
248
|
subtitle: subtitleTrack.optional(),
|
|
@@ -364,11 +365,256 @@ function readSavedEdit(data, raw) {
|
|
|
364
365
|
}
|
|
365
366
|
|
|
366
367
|
// packages/media-tools/src/video.ts
|
|
367
|
-
import {
|
|
368
|
-
import {
|
|
369
|
-
import { isAbsolute, join as join2, resolve } from "path";
|
|
368
|
+
import { readdir, rm } from "fs/promises";
|
|
369
|
+
import { join as join2 } from "path";
|
|
370
370
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
371
371
|
|
|
372
|
+
// packages/studio-os-utils/src/path.ts
|
|
373
|
+
import path from "path";
|
|
374
|
+
var WINDOWS_DRIVE_ABS = /^[A-Za-z]:[\\/]/;
|
|
375
|
+
var WINDOWS_EXTENDED_DRIVE_ABS = /^\\\\\?\\[A-Za-z]:[\\/]/;
|
|
376
|
+
var WINDOWS_EXTENDED_UNC_ABS = /^\\\\\?\\UNC\\[^\\/]+[\\/][^\\/]+/i;
|
|
377
|
+
var WINDOWS_UNC_ABS = /^\\\\(?![?.][\\/])[^\\/]+[\\/][^\\/]+/;
|
|
378
|
+
function isStrictAbsolutePath(value, options = {}) {
|
|
379
|
+
if (!value || value.includes("\0")) return false;
|
|
380
|
+
const platform = options.platform ?? process.platform;
|
|
381
|
+
if (platform === "win32") {
|
|
382
|
+
return WINDOWS_DRIVE_ABS.test(value) || WINDOWS_EXTENDED_DRIVE_ABS.test(value) || WINDOWS_EXTENDED_UNC_ABS.test(value) || WINDOWS_UNC_ABS.test(value);
|
|
383
|
+
}
|
|
384
|
+
return value.startsWith("/");
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// packages/studio-os-utils/src/env.ts
|
|
388
|
+
function getEnvValue(env, name, options = {}) {
|
|
389
|
+
if (Object.hasOwn(env, name) && env[name] !== void 0) return env[name];
|
|
390
|
+
const platform = options.platform ?? process.platform;
|
|
391
|
+
if (platform !== "win32") return void 0;
|
|
392
|
+
const target = name.toLowerCase();
|
|
393
|
+
for (const [key, value] of Object.entries(env)) {
|
|
394
|
+
if (value !== void 0 && key.toLowerCase() === target) return value;
|
|
395
|
+
}
|
|
396
|
+
return void 0;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// packages/studio-os-utils/src/executable.ts
|
|
400
|
+
import { constants } from "fs";
|
|
401
|
+
import { access as fsAccess, stat as fsStat } from "fs/promises";
|
|
402
|
+
import path2 from "path";
|
|
403
|
+
var ExecutableResolutionError = class extends Error {
|
|
404
|
+
code;
|
|
405
|
+
command;
|
|
406
|
+
platform;
|
|
407
|
+
candidatePath;
|
|
408
|
+
constructor(code, command, message, platform, candidatePath) {
|
|
409
|
+
super(message);
|
|
410
|
+
this.name = "ExecutableResolutionError";
|
|
411
|
+
this.code = code;
|
|
412
|
+
this.command = command;
|
|
413
|
+
this.platform = platform;
|
|
414
|
+
if (candidatePath !== void 0) this.candidatePath = candidatePath;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
var NATIVE_WINDOWS_EXTS = /* @__PURE__ */ new Set([".exe", ".com"]);
|
|
418
|
+
var BATCH_WRAPPER_EXTS = /* @__PURE__ */ new Set([".cmd", ".bat"]);
|
|
419
|
+
var ALLOWED_WITH_WRAPPERS_EXTS = /* @__PURE__ */ new Set([".exe", ".com", ".cmd", ".bat"]);
|
|
420
|
+
var DEFAULT_NATIVE_WINDOWS_EXT_ORDER = [".exe", ".com"];
|
|
421
|
+
var DEFAULT_PATHEXT = [".com", ".exe", ".bat", ".cmd"];
|
|
422
|
+
function cleanedWindowsExtname(filePath) {
|
|
423
|
+
const trimmed = filePath.replace(/[. ]+$/, "");
|
|
424
|
+
return path2.win32.extname(trimmed).toLowerCase();
|
|
425
|
+
}
|
|
426
|
+
function parsePathEntries(env = process.env, options = {}) {
|
|
427
|
+
const platform = options.platform ?? process.platform;
|
|
428
|
+
const rawPath = getEnvValue(env, "PATH", { platform }) ?? "";
|
|
429
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
430
|
+
const entries = [];
|
|
431
|
+
for (const part of rawPath.split(delimiter)) {
|
|
432
|
+
let entry = part.trim();
|
|
433
|
+
if (platform === "win32" && entry.length >= 2 && entry.startsWith('"') && entry.endsWith('"')) {
|
|
434
|
+
entry = entry.slice(1, -1).trim();
|
|
435
|
+
}
|
|
436
|
+
if (!entry) continue;
|
|
437
|
+
if (!isStrictAbsolutePath(entry, { platform })) continue;
|
|
438
|
+
entries.push(entry);
|
|
439
|
+
}
|
|
440
|
+
return entries;
|
|
441
|
+
}
|
|
442
|
+
function rawWindowsPathExts(env) {
|
|
443
|
+
const raw = getEnvValue(env, "PATHEXT", { platform: "win32" })?.trim();
|
|
444
|
+
const parsed = raw ? raw.split(";").map((ext) => ext.trim().toLowerCase()).filter((ext) => ext.startsWith(".") && ext.length > 1) : DEFAULT_PATHEXT;
|
|
445
|
+
return parsed.length > 0 ? [...new Set(parsed)] : DEFAULT_PATHEXT;
|
|
446
|
+
}
|
|
447
|
+
function allowedWindowsExtensions(env, allowShellWrappers) {
|
|
448
|
+
const allowSet = allowShellWrappers ? ALLOWED_WITH_WRAPPERS_EXTS : NATIVE_WINDOWS_EXTS;
|
|
449
|
+
const fromPathExt = rawWindowsPathExts(env).filter((ext) => allowSet.has(ext));
|
|
450
|
+
if (fromPathExt.length > 0) return fromPathExt;
|
|
451
|
+
return allowShellWrappers ? [".exe", ".com", ".cmd", ".bat"] : DEFAULT_NATIVE_WINDOWS_EXT_ORDER;
|
|
452
|
+
}
|
|
453
|
+
function disallowedWindowsExtensions(env, allowShellWrappers) {
|
|
454
|
+
const allowSet = allowShellWrappers ? ALLOWED_WITH_WRAPPERS_EXTS : NATIVE_WINDOWS_EXTS;
|
|
455
|
+
const candidates = /* @__PURE__ */ new Set([
|
|
456
|
+
...rawWindowsPathExts(env),
|
|
457
|
+
...allowShellWrappers ? [] : [...BATCH_WRAPPER_EXTS]
|
|
458
|
+
]);
|
|
459
|
+
return [...candidates].filter((ext) => !allowSet.has(ext));
|
|
460
|
+
}
|
|
461
|
+
function hasPathSyntax(command, platform) {
|
|
462
|
+
if (command === "." || command === "..") return true;
|
|
463
|
+
if (command.includes("/") || command.includes("\\")) return true;
|
|
464
|
+
if (platform === "win32" && /^[A-Za-z]:/.test(command)) return true;
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
async function isRunnableFile(candidate, platform, statFn, accessFn) {
|
|
468
|
+
try {
|
|
469
|
+
const info = await statFn(candidate);
|
|
470
|
+
if (!info.isFile()) return false;
|
|
471
|
+
if (platform !== "win32") await accessFn(candidate, constants.X_OK);
|
|
472
|
+
return true;
|
|
473
|
+
} catch {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
async function resolveExecutableWithHooks(command, options = {}) {
|
|
478
|
+
const platform = options.platform ?? process.platform;
|
|
479
|
+
const env = options.env ?? process.env;
|
|
480
|
+
const allowShellWrappers = options.allowShellWrappers ?? false;
|
|
481
|
+
const statFn = options.stat ?? fsStat;
|
|
482
|
+
const accessFn = options.access ?? fsAccess;
|
|
483
|
+
if (!command || !command.trim() || command.includes("\0")) {
|
|
484
|
+
throw new ExecutableResolutionError(
|
|
485
|
+
"EMPTY_COMMAND",
|
|
486
|
+
command,
|
|
487
|
+
"Executable name or path must be a non-empty string.",
|
|
488
|
+
platform
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
const pathApi = platform === "win32" ? path2.win32 : path2.posix;
|
|
492
|
+
const absolute = isStrictAbsolutePath(command, { platform });
|
|
493
|
+
if (!absolute && hasPathSyntax(command, platform)) {
|
|
494
|
+
throw new ExecutableResolutionError(
|
|
495
|
+
"RELATIVE_PATH_NOT_ALLOWED",
|
|
496
|
+
command,
|
|
497
|
+
`Executable "${command}" is a relative path; configure a bare command name on PATH or an absolute executable path.`,
|
|
498
|
+
platform
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
const allowSet = allowShellWrappers ? ALLOWED_WITH_WRAPPERS_EXTS : NATIVE_WINDOWS_EXTS;
|
|
502
|
+
const knownWinExts = /* @__PURE__ */ new Set([...rawWindowsPathExts(env), ...ALLOWED_WITH_WRAPPERS_EXTS]);
|
|
503
|
+
const cmdWinExt = platform === "win32" ? cleanedWindowsExtname(command) : "";
|
|
504
|
+
if (platform === "win32" && cmdWinExt !== "" && knownWinExts.has(cmdWinExt) && !allowSet.has(cmdWinExt)) {
|
|
505
|
+
throw new ExecutableResolutionError(
|
|
506
|
+
"UNSUPPORTED_WRAPPER",
|
|
507
|
+
command,
|
|
508
|
+
`Executable "${command}" uses unsupported Windows extension "${cmdWinExt}"; configure a native .exe/.com binary instead.`,
|
|
509
|
+
platform,
|
|
510
|
+
command
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
if (absolute) {
|
|
514
|
+
const normalized = pathApi.normalize(command);
|
|
515
|
+
if (platform === "win32") {
|
|
516
|
+
const normalizedExt = cleanedWindowsExtname(normalized);
|
|
517
|
+
if (normalizedExt !== "" && allowSet.has(normalizedExt)) {
|
|
518
|
+
if (await isRunnableFile(normalized, platform, statFn, accessFn)) {
|
|
519
|
+
return normalized;
|
|
520
|
+
}
|
|
521
|
+
throw new ExecutableResolutionError(
|
|
522
|
+
"NOT_FOUND",
|
|
523
|
+
command,
|
|
524
|
+
`Configured executable "${command}" was not found or is not runnable.`,
|
|
525
|
+
platform
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
for (const ext of allowedWindowsExtensions(env, allowShellWrappers)) {
|
|
529
|
+
const candidate = normalized + ext;
|
|
530
|
+
if (await isRunnableFile(candidate, platform, statFn, accessFn)) {
|
|
531
|
+
return candidate;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (normalizedExt !== "") {
|
|
535
|
+
throw new ExecutableResolutionError(
|
|
536
|
+
"UNSUPPORTED_WRAPPER",
|
|
537
|
+
command,
|
|
538
|
+
`Executable "${command}" uses unsupported Windows extension "${normalizedExt}"; configure a native .exe/.com binary instead.`,
|
|
539
|
+
platform,
|
|
540
|
+
command
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
for (const badExt of disallowedWindowsExtensions(env, allowShellWrappers)) {
|
|
544
|
+
const wrapperCandidate = normalized + badExt;
|
|
545
|
+
if (await isRunnableFile(wrapperCandidate, platform, statFn, accessFn)) {
|
|
546
|
+
throw new ExecutableResolutionError(
|
|
547
|
+
"UNSUPPORTED_WRAPPER",
|
|
548
|
+
command,
|
|
549
|
+
`Found non-native wrapper/script "${wrapperCandidate}" (${badExt}), which cannot be executed directly; configure a native .exe/.com binary instead.`,
|
|
550
|
+
platform,
|
|
551
|
+
wrapperCandidate
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
throw new ExecutableResolutionError(
|
|
556
|
+
"NOT_FOUND",
|
|
557
|
+
command,
|
|
558
|
+
`Configured executable "${command}" was not found or is not runnable.`,
|
|
559
|
+
platform
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
if (await isRunnableFile(normalized, platform, statFn, accessFn)) {
|
|
563
|
+
return normalized;
|
|
564
|
+
}
|
|
565
|
+
throw new ExecutableResolutionError(
|
|
566
|
+
"NOT_FOUND",
|
|
567
|
+
command,
|
|
568
|
+
`Configured executable "${command}" was not found or is not runnable.`,
|
|
569
|
+
platform
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
const dirs = parsePathEntries(env, { platform });
|
|
573
|
+
const hasKnownWinExt = platform === "win32" && cmdWinExt !== "" && knownWinExts.has(cmdWinExt);
|
|
574
|
+
const extensions = platform === "win32" && !hasKnownWinExt ? allowedWindowsExtensions(env, allowShellWrappers) : [""];
|
|
575
|
+
const disallowedExts = platform === "win32" && !hasKnownWinExt ? disallowedWindowsExtensions(env, allowShellWrappers) : [];
|
|
576
|
+
let rejectedWrapper;
|
|
577
|
+
for (const dir of dirs) {
|
|
578
|
+
for (const ext of extensions) {
|
|
579
|
+
const candidate = pathApi.join(dir, command + ext);
|
|
580
|
+
if (await isRunnableFile(candidate, platform, statFn, accessFn)) {
|
|
581
|
+
return candidate;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (disallowedExts.length > 0 && !rejectedWrapper) {
|
|
585
|
+
for (const badExt of disallowedExts) {
|
|
586
|
+
const wrapperCandidate = pathApi.join(dir, command + badExt);
|
|
587
|
+
if (await isRunnableFile(wrapperCandidate, platform, statFn, accessFn)) {
|
|
588
|
+
rejectedWrapper = wrapperCandidate;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (rejectedWrapper) {
|
|
595
|
+
throw new ExecutableResolutionError(
|
|
596
|
+
"UNSUPPORTED_WRAPPER",
|
|
597
|
+
command,
|
|
598
|
+
`Only a non-native wrapper/script "${rejectedWrapper}" was found on PATH for "${command}"; configure a native .exe/.com binary instead.`,
|
|
599
|
+
platform,
|
|
600
|
+
rejectedWrapper
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
throw new ExecutableResolutionError(
|
|
604
|
+
"NOT_FOUND",
|
|
605
|
+
command,
|
|
606
|
+
`Executable "${command}" was not found on PATH.`,
|
|
607
|
+
platform
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
async function resolveExecutable(command, options = {}) {
|
|
611
|
+
return resolveExecutableWithHooks(command, {
|
|
612
|
+
platform: options.platform,
|
|
613
|
+
env: options.env,
|
|
614
|
+
allowShellWrappers: options.allowShellWrappers
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
372
618
|
// packages/media-tools/src/executor.ts
|
|
373
619
|
import { fork } from "child_process";
|
|
374
620
|
import { existsSync } from "fs";
|
|
@@ -386,7 +632,7 @@ async function syncDirectory(directory, platform = process.platform) {
|
|
|
386
632
|
}
|
|
387
633
|
}
|
|
388
634
|
async function durableRecord(directory, name, value) {
|
|
389
|
-
const
|
|
635
|
+
const path3 = join(directory, name), temporary = path3 + "." + randomUUID() + ".tmp";
|
|
390
636
|
const file = await open(temporary, "wx", 384);
|
|
391
637
|
try {
|
|
392
638
|
await file.writeFile(JSON.stringify(value));
|
|
@@ -394,7 +640,7 @@ async function durableRecord(directory, name, value) {
|
|
|
394
640
|
} finally {
|
|
395
641
|
await file.close();
|
|
396
642
|
}
|
|
397
|
-
await rename(temporary,
|
|
643
|
+
await rename(temporary, path3);
|
|
398
644
|
await syncDirectory(directory);
|
|
399
645
|
}
|
|
400
646
|
async function commandClosed(directory, expected, requireProof = true) {
|
|
@@ -420,7 +666,7 @@ async function commandClosed(directory, expected, requireProof = true) {
|
|
|
420
666
|
return true;
|
|
421
667
|
} catch {
|
|
422
668
|
}
|
|
423
|
-
await new Promise((
|
|
669
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
424
670
|
} while (Date.now() < deadline);
|
|
425
671
|
} catch {
|
|
426
672
|
}
|
|
@@ -467,14 +713,14 @@ var NativeExecutor = class {
|
|
|
467
713
|
child.stderr?.on("data", (chunk) => {
|
|
468
714
|
stderr = (stderr + chunk.toString()).slice(-4096);
|
|
469
715
|
});
|
|
470
|
-
return await new Promise((
|
|
716
|
+
return await new Promise((resolve, reject) => {
|
|
471
717
|
let settled = false, confirmed = false, result, resultError;
|
|
472
718
|
const finish = (error, value) => {
|
|
473
719
|
if (settled) return;
|
|
474
720
|
settled = true;
|
|
475
721
|
options.signal?.removeEventListener("abort", cancel);
|
|
476
722
|
if (error) reject(error);
|
|
477
|
-
else
|
|
723
|
+
else resolve(value);
|
|
478
724
|
};
|
|
479
725
|
const cancel = () => {
|
|
480
726
|
if (child.connected) child.send({ type: "cancel" });
|
|
@@ -592,13 +838,13 @@ var NativeExecutor = class {
|
|
|
592
838
|
const child = this.child;
|
|
593
839
|
if (!child) return;
|
|
594
840
|
if (child.connected) child.send({ type: "cancel" });
|
|
595
|
-
await new Promise((
|
|
841
|
+
await new Promise((resolve) => {
|
|
596
842
|
let done = false;
|
|
597
843
|
const finish = () => {
|
|
598
844
|
if (done) return;
|
|
599
845
|
done = true;
|
|
600
846
|
clearTimeout(timer);
|
|
601
|
-
|
|
847
|
+
resolve();
|
|
602
848
|
};
|
|
603
849
|
const timer = setTimeout(() => {
|
|
604
850
|
this.blocked = true;
|
|
@@ -818,19 +1064,32 @@ function validateFrameTiming(actual, timings, fps, webm = false) {
|
|
|
818
1064
|
}
|
|
819
1065
|
|
|
820
1066
|
// packages/media-tools/src/video.ts
|
|
821
|
-
async function
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
1067
|
+
async function resolveMediaExecutable(name, options = {}, resolver = resolveExecutable) {
|
|
1068
|
+
try {
|
|
1069
|
+
return await resolver(name, { ...options, allowShellWrappers: false });
|
|
1070
|
+
} catch (error) {
|
|
1071
|
+
if (error instanceof ExecutableResolutionError) {
|
|
1072
|
+
if (error.code === "RELATIVE_PATH_NOT_ALLOWED") {
|
|
1073
|
+
mediaError(
|
|
1074
|
+
"TOOL_UNAVAILABLE",
|
|
1075
|
+
"Configure ffmpegPath/ffprobePath as a bare command name on PATH (e.g. ffmpeg) or an explicit absolute path."
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
if (error.code === "UNSUPPORTED_WRAPPER") {
|
|
1079
|
+
mediaError(
|
|
1080
|
+
"TOOL_UNAVAILABLE",
|
|
1081
|
+
"Windows wrapper or script files (.cmd/.bat/.ps1/.py) cannot be run directly for FFmpeg/ffprobe. Configure the absolute path to ffmpeg.exe/ffprobe.exe."
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
828
1084
|
}
|
|
1085
|
+
mediaError(
|
|
1086
|
+
"TOOL_UNAVAILABLE",
|
|
1087
|
+
"Install the configured FFmpeg and ffprobe executables, ensure they are on PATH (or set absolute ffmpegPath/ffprobePath), and restart Studio Host."
|
|
1088
|
+
);
|
|
829
1089
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
);
|
|
1090
|
+
}
|
|
1091
|
+
async function executable(name) {
|
|
1092
|
+
return resolveMediaExecutable(name);
|
|
834
1093
|
}
|
|
835
1094
|
function fraction(value) {
|
|
836
1095
|
const [a, b] = String(value).split("/").map(Number);
|
|
@@ -1069,7 +1328,7 @@ var Videos = class {
|
|
|
1069
1328
|
}
|
|
1070
1329
|
}
|
|
1071
1330
|
async timedInput(descriptor, tools, copy, job) {
|
|
1072
|
-
const { absolutePath:
|
|
1331
|
+
const { absolutePath: path3 } = await this.restoreMetadata(descriptor, copy);
|
|
1073
1332
|
const key = JSON.stringify([descriptor.metadata.sha256, tools.ffprobe, tools.ffprobeVersion]);
|
|
1074
1333
|
let frames = this.frameCache.get(key);
|
|
1075
1334
|
if (!frames) {
|
|
@@ -1084,14 +1343,14 @@ var Videos = class {
|
|
|
1084
1343
|
"frame=best_effort_timestamp_time",
|
|
1085
1344
|
"-of",
|
|
1086
1345
|
"csv=p=0",
|
|
1087
|
-
|
|
1346
|
+
path3
|
|
1088
1347
|
];
|
|
1089
1348
|
const result = job ? await this.native.run(tools.ffprobe, args, { ...job, timeoutMs: 15e3 }) : await this.command(tools.ffprobe, args);
|
|
1090
1349
|
frames = frameTimes(result.stdout);
|
|
1091
1350
|
if (this.frameCache.size >= 64) this.frameCache.delete(this.frameCache.keys().next().value);
|
|
1092
1351
|
this.frameCache.set(key, frames);
|
|
1093
1352
|
}
|
|
1094
|
-
return { descriptor, path, timing: segmentTiming(descriptor, frames) };
|
|
1353
|
+
return { descriptor, path: path3, timing: segmentTiming(descriptor, frames) };
|
|
1095
1354
|
}
|
|
1096
1355
|
async master(file) {
|
|
1097
1356
|
const record = this.file(file, false, true);
|
|
@@ -1302,7 +1561,7 @@ var timelineSchema = z5.array(
|
|
|
1302
1561
|
end: z5.number().finite(),
|
|
1303
1562
|
duration: z5.number().positive()
|
|
1304
1563
|
})
|
|
1305
|
-
).min(1).max(
|
|
1564
|
+
).min(1).max(maxSequenceInputs);
|
|
1306
1565
|
var audioSnapshot = z5.object({
|
|
1307
1566
|
inputs: audioQuery.shape.inputs,
|
|
1308
1567
|
sequenceKey: z5.uuid(),
|
|
@@ -4886,8 +5145,8 @@ function line(ctx, x1, y1, x2, y2) {
|
|
|
4886
5145
|
ctx.stroke();
|
|
4887
5146
|
}
|
|
4888
5147
|
var draw = { line };
|
|
4889
|
-
function getPathDefinition(glyph,
|
|
4890
|
-
var _path =
|
|
5148
|
+
function getPathDefinition(glyph, path3) {
|
|
5149
|
+
var _path = path3 || new Path();
|
|
4891
5150
|
return {
|
|
4892
5151
|
configurable: true,
|
|
4893
5152
|
get: function() {
|
|
@@ -5070,9 +5329,9 @@ Glyph.prototype.drawPoints = function(ctx, x, y, fontSize) {
|
|
|
5070
5329
|
var scale = 1 / this.path.unitsPerEm * fontSize;
|
|
5071
5330
|
var blueCircles = [];
|
|
5072
5331
|
var redCircles = [];
|
|
5073
|
-
var
|
|
5074
|
-
for (var i = 0; i <
|
|
5075
|
-
var cmd =
|
|
5332
|
+
var path3 = this.path;
|
|
5333
|
+
for (var i = 0; i < path3.commands.length; i += 1) {
|
|
5334
|
+
var cmd = path3.commands[i];
|
|
5076
5335
|
if (cmd.x !== void 0) {
|
|
5077
5336
|
blueCircles.push({ x: cmd.x, y: -cmd.y });
|
|
5078
5337
|
}
|
|
@@ -5179,9 +5438,9 @@ function ttfGlyphLoader(font, index, parseGlyph2, data, position, buildPath2) {
|
|
|
5179
5438
|
var glyph = new Glyph({ index, font });
|
|
5180
5439
|
glyph.path = function() {
|
|
5181
5440
|
parseGlyph2(glyph, data, position);
|
|
5182
|
-
var
|
|
5183
|
-
|
|
5184
|
-
return
|
|
5441
|
+
var path3 = buildPath2(font.glyphs, glyph);
|
|
5442
|
+
path3.unitsPerEm = font.unitsPerEm;
|
|
5443
|
+
return path3;
|
|
5185
5444
|
};
|
|
5186
5445
|
defineDependentProperty(glyph, "xMin", "_xMin");
|
|
5187
5446
|
defineDependentProperty(glyph, "xMax", "_xMax");
|
|
@@ -5194,9 +5453,9 @@ function cffGlyphLoader(font, index, parseCFFCharstring2, charstring) {
|
|
|
5194
5453
|
return function() {
|
|
5195
5454
|
var glyph = new Glyph({ index, font });
|
|
5196
5455
|
glyph.path = function() {
|
|
5197
|
-
var
|
|
5198
|
-
|
|
5199
|
-
return
|
|
5456
|
+
var path3 = parseCFFCharstring2(font, glyph, charstring);
|
|
5457
|
+
path3.unitsPerEm = font.unitsPerEm;
|
|
5458
|
+
return path3;
|
|
5200
5459
|
};
|
|
5201
5460
|
return glyph;
|
|
5202
5461
|
};
|
|
@@ -6158,14 +6417,14 @@ function makeCharsets(glyphNames, strings) {
|
|
|
6158
6417
|
}
|
|
6159
6418
|
function glyphToOps(glyph) {
|
|
6160
6419
|
var ops = [];
|
|
6161
|
-
var
|
|
6420
|
+
var path3 = glyph.path;
|
|
6162
6421
|
ops.push({ name: "width", type: "NUMBER", value: glyph.advanceWidth });
|
|
6163
6422
|
var x = 0;
|
|
6164
6423
|
var y = 0;
|
|
6165
|
-
for (var i = 0; i <
|
|
6424
|
+
for (var i = 0; i < path3.commands.length; i += 1) {
|
|
6166
6425
|
var dx = void 0;
|
|
6167
6426
|
var dy = void 0;
|
|
6168
|
-
var cmd =
|
|
6427
|
+
var cmd = path3.commands[i];
|
|
6169
6428
|
if (cmd.type === "Q") {
|
|
6170
6429
|
var _13 = 1 / 3;
|
|
6171
6430
|
var _23 = 2 / 3;
|
|
@@ -14566,10 +14825,10 @@ async function writeOverlay(data, track, canvas2, dir) {
|
|
|
14566
14825
|
at = c.end;
|
|
14567
14826
|
}
|
|
14568
14827
|
manifest.push("file blank.png", "option framerate 1000");
|
|
14569
|
-
const
|
|
14570
|
-
await writeFile(
|
|
14828
|
+
const path3 = join3(dir, "subtitles.ffconcat");
|
|
14829
|
+
await writeFile(path3, manifest.join("\n") + "\n");
|
|
14571
14830
|
return {
|
|
14572
|
-
path,
|
|
14831
|
+
path: path3,
|
|
14573
14832
|
cues: result.cues.map(({ start, end }) => ({ start, end })),
|
|
14574
14833
|
width: canvas2.width,
|
|
14575
14834
|
top: Math.round(result.top * canvas2.height / result.height)
|
|
@@ -14600,14 +14859,14 @@ function mixGraph(clips, mix, tracks, trackPaths, duration) {
|
|
|
14600
14859
|
const paths = /* @__PURE__ */ new Map();
|
|
14601
14860
|
const filters = [], voice = [], background = [], other = [];
|
|
14602
14861
|
let count = 0;
|
|
14603
|
-
function place(
|
|
14862
|
+
function place(path3, origin, sourceLength, length, at2, channels, gain2, role, speed, fadeIn = 0, fadeOut = 0) {
|
|
14604
14863
|
if (length <= 0)
|
|
14605
14864
|
mediaError("INVALID_MIX_RANGE", "An audio item falls outside the rendered picture.");
|
|
14606
|
-
let index = paths.get(
|
|
14865
|
+
let index = paths.get(path3);
|
|
14607
14866
|
if (index === void 0) {
|
|
14608
14867
|
index = paths.size;
|
|
14609
|
-
paths.set(
|
|
14610
|
-
args.push("-protocol_whitelist", "file,pipe", "-i",
|
|
14868
|
+
paths.set(path3, index);
|
|
14869
|
+
args.push("-protocol_whitelist", "file,pipe", "-i", path3);
|
|
14611
14870
|
}
|
|
14612
14871
|
const label = "part" + count++;
|
|
14613
14872
|
const chain = [
|
|
@@ -14634,12 +14893,12 @@ function mixGraph(clips, mix, tracks, trackPaths, duration) {
|
|
|
14634
14893
|
bus.push("[" + label + "]");
|
|
14635
14894
|
}
|
|
14636
14895
|
let at = 0;
|
|
14637
|
-
for (const [index, { path, descriptor, timing }] of clips.entries()) {
|
|
14896
|
+
for (const [index, { path: path3, descriptor, timing }] of clips.entries()) {
|
|
14638
14897
|
const original = mix.originals?.find((o) => o.inputIndex === index);
|
|
14639
14898
|
const gain2 = original ? original.gainDb : mix.originalGainDb;
|
|
14640
14899
|
if (descriptor.metadata.hasAudio && gain2 !== null)
|
|
14641
14900
|
place(
|
|
14642
|
-
|
|
14901
|
+
path3,
|
|
14643
14902
|
timing.start,
|
|
14644
14903
|
timing.end - timing.start,
|
|
14645
14904
|
timing.duration,
|
|
@@ -14698,14 +14957,14 @@ function levels(stderr) {
|
|
|
14698
14957
|
mediaError("LOUDNESS_MEASUREMENT_FAILED", "FFmpeg did not return a loudness report.");
|
|
14699
14958
|
return JSON.parse(values[0]);
|
|
14700
14959
|
}
|
|
14701
|
-
async function measureOutput(native, ffmpeg,
|
|
14960
|
+
async function measureOutput(native, ffmpeg, path3, options) {
|
|
14702
14961
|
const result = await native.run(
|
|
14703
14962
|
ffmpeg,
|
|
14704
14963
|
[
|
|
14705
14964
|
"-hide_banner",
|
|
14706
14965
|
"-nostdin",
|
|
14707
14966
|
"-i",
|
|
14708
|
-
|
|
14967
|
+
path3,
|
|
14709
14968
|
"-vn",
|
|
14710
14969
|
"-af",
|
|
14711
14970
|
norm + ":print_format=json",
|
|
@@ -14768,18 +15027,18 @@ async function renderAudio(native, ffmpeg, clips, audio, paths, duration, output
|
|
|
14768
15027
|
);
|
|
14769
15028
|
return output;
|
|
14770
15029
|
}
|
|
14771
|
-
function copyPicture(
|
|
15030
|
+
function copyPicture(path3, start, mixed, profile, output, gainDb = 0) {
|
|
14772
15031
|
return [
|
|
14773
15032
|
"-hide_banner",
|
|
14774
15033
|
"-nostdin",
|
|
14775
15034
|
"-y",
|
|
14776
15035
|
"-copyts",
|
|
14777
|
-
...
|
|
15036
|
+
...path3 ? ["-protocol_whitelist", "file,pipe", "-i", path3] : [],
|
|
14778
15037
|
...mixed ? ["-itsoffset", String(start), "-protocol_whitelist", "file,pipe", "-i", mixed] : [],
|
|
14779
|
-
...
|
|
15038
|
+
...path3 ? ["-map", "0:v:0", "-c:v", "copy"] : ["-vn"],
|
|
14780
15039
|
...mixed ? [
|
|
14781
15040
|
"-map",
|
|
14782
|
-
|
|
15041
|
+
path3 ? "1:a:0" : "0:a:0",
|
|
14783
15042
|
...gainDb ? ["-af", "volume=" + gainDb + "dB"] : [],
|
|
14784
15043
|
"-c:a",
|
|
14785
15044
|
profile.audio === "opus" ? "libopus" : "aac",
|
|
@@ -14962,7 +15221,7 @@ var toolsSchema = z6.object({
|
|
|
14962
15221
|
var snapshot = z6.object({
|
|
14963
15222
|
request: mediaRequest,
|
|
14964
15223
|
audio: audioSnapshot.optional(),
|
|
14965
|
-
descriptors: z6.array(editDescriptor).min(1).max(
|
|
15224
|
+
descriptors: z6.array(editDescriptor).min(1).max(maxSequenceInputs),
|
|
14966
15225
|
tools: toolsSchema
|
|
14967
15226
|
}).strict();
|
|
14968
15227
|
var jobData = z6.object({
|
|
@@ -15165,8 +15424,8 @@ var Jobs = class {
|
|
|
15165
15424
|
await this.videos.restoreMetadata(descriptor, Boolean(audio?.copy));
|
|
15166
15425
|
for (const executable2 of [tools.ffmpeg, tools.ffprobe]) {
|
|
15167
15426
|
try {
|
|
15168
|
-
const { access
|
|
15169
|
-
await
|
|
15427
|
+
const { access } = await import("fs/promises");
|
|
15428
|
+
await access(executable2);
|
|
15170
15429
|
} catch {
|
|
15171
15430
|
mediaError(
|
|
15172
15431
|
"EXECUTION_CONFIG_UNAVAILABLE",
|
|
@@ -15466,10 +15725,10 @@ var Jobs = class {
|
|
|
15466
15725
|
if (audio?.timeline && audio.mix) {
|
|
15467
15726
|
const override = audio.mix.originals?.find((o) => o.inputIndex === index);
|
|
15468
15727
|
const gain2 = override ? override.gainDb : audio.mix.originalGainDb;
|
|
15469
|
-
const
|
|
15728
|
+
const path3 = descriptor.metadata.hasAudio && gain2 !== null ? (await this.videos.restoreMetadata(descriptor, true)).absolutePath : "";
|
|
15470
15729
|
inputs.push({
|
|
15471
15730
|
descriptor,
|
|
15472
|
-
path,
|
|
15731
|
+
path: path3,
|
|
15473
15732
|
timing: { ...audio.timeline[index], frames: [], tolerance: 0 }
|
|
15474
15733
|
});
|
|
15475
15734
|
} else inputs.push(await timedInput(descriptor));
|
|
@@ -15634,9 +15893,9 @@ var Jobs = class {
|
|
|
15634
15893
|
onPrepared: (stagingFileId) => {
|
|
15635
15894
|
row = this.update(id, { stagingFileId });
|
|
15636
15895
|
},
|
|
15637
|
-
probeRunner: (
|
|
15896
|
+
probeRunner: (path3, signal, context) => this.native.run(
|
|
15638
15897
|
d.snapshot.tools.ffprobe,
|
|
15639
|
-
["-v", "error", "-show_format", "-show_streams", "-of", "json",
|
|
15898
|
+
["-v", "error", "-show_format", "-show_streams", "-of", "json", path3],
|
|
15640
15899
|
{ ...commandOptions, directory: context.directory, signal, timeoutMs: 15e3 }
|
|
15641
15900
|
)
|
|
15642
15901
|
}
|
|
@@ -15790,7 +16049,7 @@ var Jobs = class {
|
|
|
15790
16049
|
this.active?.abort.abort();
|
|
15791
16050
|
await this.native.dispose();
|
|
15792
16051
|
if (this.pumping)
|
|
15793
|
-
await Promise.race([this.pumping, new Promise((
|
|
16052
|
+
await Promise.race([this.pumping, new Promise((resolve) => setTimeout(resolve, 6e3))]);
|
|
15794
16053
|
for (const row of this.rows())
|
|
15795
16054
|
if (row.data.state === "queued") {
|
|
15796
16055
|
try {
|
package/dist/shared.d.ts
CHANGED
|
@@ -302,6 +302,7 @@ declare const sequenceVideoInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
302
302
|
}, z.core.$strict>;
|
|
303
303
|
}, z.core.$strict>], "kind">;
|
|
304
304
|
type SequenceVideoInput = z.infer<typeof sequenceVideoInput>;
|
|
305
|
+
declare const maxSequenceInputs = 64;
|
|
305
306
|
declare const colorAdjustment: z.ZodObject<{
|
|
306
307
|
brightness: z.ZodNumber;
|
|
307
308
|
contrast: z.ZodNumber;
|
|
@@ -529,7 +530,6 @@ declare const audioMix: z.ZodObject<{
|
|
|
529
530
|
}>>;
|
|
530
531
|
}, z.core.$strict>;
|
|
531
532
|
type AudioMix = z.infer<typeof audioMix>;
|
|
532
|
-
declare const maxSequenceInputs = 64;
|
|
533
533
|
declare const audioQuery: z.ZodObject<{
|
|
534
534
|
inputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
535
535
|
kind: z.ZodLiteral<"source">;
|
package/dist/shared.js
CHANGED
|
@@ -138,6 +138,8 @@ var sequenceVideoInput = z3.discriminatedUnion("kind", [
|
|
|
138
138
|
sourceInput.extend({ trimEndMs: z3.number().int().positive().optional() }),
|
|
139
139
|
editInput
|
|
140
140
|
]);
|
|
141
|
+
var maxSequenceInputs = 64;
|
|
142
|
+
var sequenceInputs = z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs);
|
|
141
143
|
var colorAdjustment = z3.object({
|
|
142
144
|
brightness: z3.number().finite().min(-0.5).max(0.5),
|
|
143
145
|
contrast: z3.number().finite().min(0).max(2),
|
|
@@ -215,11 +217,11 @@ var audioMix = z3.object({
|
|
|
215
217
|
originalGainDb: gain.nullable().optional(),
|
|
216
218
|
originals: z3.array(
|
|
217
219
|
z3.object({
|
|
218
|
-
inputIndex: z3.number().int().min(0).max(
|
|
220
|
+
inputIndex: z3.number().int().min(0).max(maxSequenceInputs - 1),
|
|
219
221
|
gainDb: gain.nullable(),
|
|
220
222
|
role: z3.enum(["dialogue", "ambience"]).optional()
|
|
221
223
|
}).strict()
|
|
222
|
-
).max(
|
|
224
|
+
).max(maxSequenceInputs).optional(),
|
|
223
225
|
tracks: z3.array(
|
|
224
226
|
z3.object({
|
|
225
227
|
id: z3.string().trim().min(1).max(128),
|
|
@@ -236,8 +238,7 @@ var audioMix = z3.object({
|
|
|
236
238
|
ducking: z3.boolean().optional(),
|
|
237
239
|
loudness: z3.enum(["studio-web-v1", "off"]).optional()
|
|
238
240
|
}).strict();
|
|
239
|
-
var
|
|
240
|
-
var audioQuery = z3.object({ inputs: z3.array(sequenceVideoInput).min(1).max(maxSequenceInputs) }).strict();
|
|
241
|
+
var audioQuery = z3.object({ inputs: sequenceInputs }).strict();
|
|
241
242
|
var previewQuery = audioQuery.extend({
|
|
242
243
|
knownRevision: z3.number().int().nonnegative().optional()
|
|
243
244
|
});
|
|
@@ -297,7 +298,7 @@ var exportSettings = z3.object({
|
|
|
297
298
|
audio: z3.boolean()
|
|
298
299
|
}).strict();
|
|
299
300
|
var processSequence = z3.object({
|
|
300
|
-
inputs:
|
|
301
|
+
inputs: sequenceInputs,
|
|
301
302
|
outputName,
|
|
302
303
|
canvas,
|
|
303
304
|
subtitle: subtitleTrack.optional(),
|
package/dist/worker.js
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
3
|
import { mkdir, open, rename, stat } from "fs/promises";
|
|
4
4
|
import { join } from "path";
|
|
5
|
+
|
|
6
|
+
// packages/studio-os-utils/src/env.ts
|
|
7
|
+
var CREDENTIAL_KEY_PATTERN = /(?:^|_)(?:KEY|KEYS|PASSWORD|PASSWD|SECRET|SECRETS|TOKEN|TOKENS|AUTH|CREDENTIAL|CREDENTIALS|DSN|COOKIE|COOKIES|PRIVATE)(?:$|_)|(?:APIKEY|API_KEY|ACCESS_KEY|SECRET_KEY|PRIVATE_KEY|AUTH_TOKEN|ACCESS_TOKEN|REFRESH_TOKEN|CLIENT_SECRET|DATABASE_URL|CONNECTION_STRING)/i;
|
|
8
|
+
function scrubChildEnv(env = process.env, options = {}) {
|
|
9
|
+
const platform = options.platform ?? process.platform;
|
|
10
|
+
const allowSet = new Set(
|
|
11
|
+
(options.allow ?? []).map((name) => platform === "win32" ? name.toLowerCase() : name)
|
|
12
|
+
);
|
|
13
|
+
const cleaned = {};
|
|
14
|
+
for (const [key, value] of Object.entries(env)) {
|
|
15
|
+
if (value === void 0) continue;
|
|
16
|
+
const lookupKey = platform === "win32" ? key.toLowerCase() : key;
|
|
17
|
+
if (CREDENTIAL_KEY_PATTERN.test(key) && !allowSet.has(lookupKey)) continue;
|
|
18
|
+
cleaned[key] = value;
|
|
19
|
+
}
|
|
20
|
+
if (options.overrides) {
|
|
21
|
+
for (const [key, value] of Object.entries(options.overrides)) {
|
|
22
|
+
if (platform === "win32") {
|
|
23
|
+
const lower = key.toLowerCase();
|
|
24
|
+
for (const existing of Object.keys(cleaned)) {
|
|
25
|
+
if (existing.toLowerCase() === lower) delete cleaned[existing];
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
delete cleaned[key];
|
|
29
|
+
}
|
|
30
|
+
if (value !== void 0) cleaned[key] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return cleaned;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// packages/media-tools/src/worker.ts
|
|
5
37
|
var child;
|
|
6
38
|
var disconnected = false;
|
|
7
39
|
var stopping = false;
|
|
@@ -101,6 +133,7 @@ process.on("message", async (message) => {
|
|
|
101
133
|
}
|
|
102
134
|
child = spawn(command.command, command.args, {
|
|
103
135
|
shell: false,
|
|
136
|
+
env: scrubChildEnv(process.env),
|
|
104
137
|
stdio: ["ignore", "pipe", "pipe"],
|
|
105
138
|
windowsHide: true
|
|
106
139
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivix-labs/media-tools",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@resvg/resvg-wasm": "2.6.2",
|
|
47
47
|
"@types/opentype.js": "^1.3.10",
|
|
48
|
+
"@vivix-labs/studio-os-utils": "workspace:*",
|
|
48
49
|
"@vivix-labs/ui-system": "workspace:*",
|
|
49
50
|
"opentype.js": "1.3.4"
|
|
50
51
|
},
|