@vivix-labs/media-tools 1.0.0-beta.22 → 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 +336 -73
- package/dist/shared.d.ts +5 -5
- package/dist/shared.js +6 -5
- package/dist/worker.js +43 -6
- 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";
|
|
@@ -376,8 +622,17 @@ import { mkdir, open, rename, readFile } from "fs/promises";
|
|
|
376
622
|
import { join } from "path";
|
|
377
623
|
import { fileURLToPath } from "url";
|
|
378
624
|
import { randomUUID } from "crypto";
|
|
625
|
+
async function syncDirectory(directory, platform = process.platform) {
|
|
626
|
+
if (platform === "win32") return;
|
|
627
|
+
const parent = await open(directory, "r");
|
|
628
|
+
try {
|
|
629
|
+
await parent.sync();
|
|
630
|
+
} finally {
|
|
631
|
+
await parent.close();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
379
634
|
async function durableRecord(directory, name, value) {
|
|
380
|
-
const
|
|
635
|
+
const path3 = join(directory, name), temporary = path3 + "." + randomUUID() + ".tmp";
|
|
381
636
|
const file = await open(temporary, "wx", 384);
|
|
382
637
|
try {
|
|
383
638
|
await file.writeFile(JSON.stringify(value));
|
|
@@ -385,13 +640,8 @@ async function durableRecord(directory, name, value) {
|
|
|
385
640
|
} finally {
|
|
386
641
|
await file.close();
|
|
387
642
|
}
|
|
388
|
-
await rename(temporary,
|
|
389
|
-
|
|
390
|
-
try {
|
|
391
|
-
await parent.sync();
|
|
392
|
-
} finally {
|
|
393
|
-
await parent.close();
|
|
394
|
-
}
|
|
643
|
+
await rename(temporary, path3);
|
|
644
|
+
await syncDirectory(directory);
|
|
395
645
|
}
|
|
396
646
|
async function commandClosed(directory, expected, requireProof = true) {
|
|
397
647
|
let identity;
|
|
@@ -416,7 +666,7 @@ async function commandClosed(directory, expected, requireProof = true) {
|
|
|
416
666
|
return true;
|
|
417
667
|
} catch {
|
|
418
668
|
}
|
|
419
|
-
await new Promise((
|
|
669
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
420
670
|
} while (Date.now() < deadline);
|
|
421
671
|
} catch {
|
|
422
672
|
}
|
|
@@ -463,14 +713,14 @@ var NativeExecutor = class {
|
|
|
463
713
|
child.stderr?.on("data", (chunk) => {
|
|
464
714
|
stderr = (stderr + chunk.toString()).slice(-4096);
|
|
465
715
|
});
|
|
466
|
-
return await new Promise((
|
|
716
|
+
return await new Promise((resolve, reject) => {
|
|
467
717
|
let settled = false, confirmed = false, result, resultError;
|
|
468
718
|
const finish = (error, value) => {
|
|
469
719
|
if (settled) return;
|
|
470
720
|
settled = true;
|
|
471
721
|
options.signal?.removeEventListener("abort", cancel);
|
|
472
722
|
if (error) reject(error);
|
|
473
|
-
else
|
|
723
|
+
else resolve(value);
|
|
474
724
|
};
|
|
475
725
|
const cancel = () => {
|
|
476
726
|
if (child.connected) child.send({ type: "cancel" });
|
|
@@ -588,13 +838,13 @@ var NativeExecutor = class {
|
|
|
588
838
|
const child = this.child;
|
|
589
839
|
if (!child) return;
|
|
590
840
|
if (child.connected) child.send({ type: "cancel" });
|
|
591
|
-
await new Promise((
|
|
841
|
+
await new Promise((resolve) => {
|
|
592
842
|
let done = false;
|
|
593
843
|
const finish = () => {
|
|
594
844
|
if (done) return;
|
|
595
845
|
done = true;
|
|
596
846
|
clearTimeout(timer);
|
|
597
|
-
|
|
847
|
+
resolve();
|
|
598
848
|
};
|
|
599
849
|
const timer = setTimeout(() => {
|
|
600
850
|
this.blocked = true;
|
|
@@ -814,19 +1064,32 @@ function validateFrameTiming(actual, timings, fps, webm = false) {
|
|
|
814
1064
|
}
|
|
815
1065
|
|
|
816
1066
|
// packages/media-tools/src/video.ts
|
|
817
|
-
async function
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
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
|
+
}
|
|
824
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
|
+
);
|
|
825
1089
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
);
|
|
1090
|
+
}
|
|
1091
|
+
async function executable(name) {
|
|
1092
|
+
return resolveMediaExecutable(name);
|
|
830
1093
|
}
|
|
831
1094
|
function fraction(value) {
|
|
832
1095
|
const [a, b] = String(value).split("/").map(Number);
|
|
@@ -1065,7 +1328,7 @@ var Videos = class {
|
|
|
1065
1328
|
}
|
|
1066
1329
|
}
|
|
1067
1330
|
async timedInput(descriptor, tools, copy, job) {
|
|
1068
|
-
const { absolutePath:
|
|
1331
|
+
const { absolutePath: path3 } = await this.restoreMetadata(descriptor, copy);
|
|
1069
1332
|
const key = JSON.stringify([descriptor.metadata.sha256, tools.ffprobe, tools.ffprobeVersion]);
|
|
1070
1333
|
let frames = this.frameCache.get(key);
|
|
1071
1334
|
if (!frames) {
|
|
@@ -1080,14 +1343,14 @@ var Videos = class {
|
|
|
1080
1343
|
"frame=best_effort_timestamp_time",
|
|
1081
1344
|
"-of",
|
|
1082
1345
|
"csv=p=0",
|
|
1083
|
-
|
|
1346
|
+
path3
|
|
1084
1347
|
];
|
|
1085
1348
|
const result = job ? await this.native.run(tools.ffprobe, args, { ...job, timeoutMs: 15e3 }) : await this.command(tools.ffprobe, args);
|
|
1086
1349
|
frames = frameTimes(result.stdout);
|
|
1087
1350
|
if (this.frameCache.size >= 64) this.frameCache.delete(this.frameCache.keys().next().value);
|
|
1088
1351
|
this.frameCache.set(key, frames);
|
|
1089
1352
|
}
|
|
1090
|
-
return { descriptor, path, timing: segmentTiming(descriptor, frames) };
|
|
1353
|
+
return { descriptor, path: path3, timing: segmentTiming(descriptor, frames) };
|
|
1091
1354
|
}
|
|
1092
1355
|
async master(file) {
|
|
1093
1356
|
const record = this.file(file, false, true);
|
|
@@ -1298,7 +1561,7 @@ var timelineSchema = z5.array(
|
|
|
1298
1561
|
end: z5.number().finite(),
|
|
1299
1562
|
duration: z5.number().positive()
|
|
1300
1563
|
})
|
|
1301
|
-
).min(1).max(
|
|
1564
|
+
).min(1).max(maxSequenceInputs);
|
|
1302
1565
|
var audioSnapshot = z5.object({
|
|
1303
1566
|
inputs: audioQuery.shape.inputs,
|
|
1304
1567
|
sequenceKey: z5.uuid(),
|
|
@@ -4882,8 +5145,8 @@ function line(ctx, x1, y1, x2, y2) {
|
|
|
4882
5145
|
ctx.stroke();
|
|
4883
5146
|
}
|
|
4884
5147
|
var draw = { line };
|
|
4885
|
-
function getPathDefinition(glyph,
|
|
4886
|
-
var _path =
|
|
5148
|
+
function getPathDefinition(glyph, path3) {
|
|
5149
|
+
var _path = path3 || new Path();
|
|
4887
5150
|
return {
|
|
4888
5151
|
configurable: true,
|
|
4889
5152
|
get: function() {
|
|
@@ -5066,9 +5329,9 @@ Glyph.prototype.drawPoints = function(ctx, x, y, fontSize) {
|
|
|
5066
5329
|
var scale = 1 / this.path.unitsPerEm * fontSize;
|
|
5067
5330
|
var blueCircles = [];
|
|
5068
5331
|
var redCircles = [];
|
|
5069
|
-
var
|
|
5070
|
-
for (var i = 0; i <
|
|
5071
|
-
var cmd =
|
|
5332
|
+
var path3 = this.path;
|
|
5333
|
+
for (var i = 0; i < path3.commands.length; i += 1) {
|
|
5334
|
+
var cmd = path3.commands[i];
|
|
5072
5335
|
if (cmd.x !== void 0) {
|
|
5073
5336
|
blueCircles.push({ x: cmd.x, y: -cmd.y });
|
|
5074
5337
|
}
|
|
@@ -5175,9 +5438,9 @@ function ttfGlyphLoader(font, index, parseGlyph2, data, position, buildPath2) {
|
|
|
5175
5438
|
var glyph = new Glyph({ index, font });
|
|
5176
5439
|
glyph.path = function() {
|
|
5177
5440
|
parseGlyph2(glyph, data, position);
|
|
5178
|
-
var
|
|
5179
|
-
|
|
5180
|
-
return
|
|
5441
|
+
var path3 = buildPath2(font.glyphs, glyph);
|
|
5442
|
+
path3.unitsPerEm = font.unitsPerEm;
|
|
5443
|
+
return path3;
|
|
5181
5444
|
};
|
|
5182
5445
|
defineDependentProperty(glyph, "xMin", "_xMin");
|
|
5183
5446
|
defineDependentProperty(glyph, "xMax", "_xMax");
|
|
@@ -5190,9 +5453,9 @@ function cffGlyphLoader(font, index, parseCFFCharstring2, charstring) {
|
|
|
5190
5453
|
return function() {
|
|
5191
5454
|
var glyph = new Glyph({ index, font });
|
|
5192
5455
|
glyph.path = function() {
|
|
5193
|
-
var
|
|
5194
|
-
|
|
5195
|
-
return
|
|
5456
|
+
var path3 = parseCFFCharstring2(font, glyph, charstring);
|
|
5457
|
+
path3.unitsPerEm = font.unitsPerEm;
|
|
5458
|
+
return path3;
|
|
5196
5459
|
};
|
|
5197
5460
|
return glyph;
|
|
5198
5461
|
};
|
|
@@ -6154,14 +6417,14 @@ function makeCharsets(glyphNames, strings) {
|
|
|
6154
6417
|
}
|
|
6155
6418
|
function glyphToOps(glyph) {
|
|
6156
6419
|
var ops = [];
|
|
6157
|
-
var
|
|
6420
|
+
var path3 = glyph.path;
|
|
6158
6421
|
ops.push({ name: "width", type: "NUMBER", value: glyph.advanceWidth });
|
|
6159
6422
|
var x = 0;
|
|
6160
6423
|
var y = 0;
|
|
6161
|
-
for (var i = 0; i <
|
|
6424
|
+
for (var i = 0; i < path3.commands.length; i += 1) {
|
|
6162
6425
|
var dx = void 0;
|
|
6163
6426
|
var dy = void 0;
|
|
6164
|
-
var cmd =
|
|
6427
|
+
var cmd = path3.commands[i];
|
|
6165
6428
|
if (cmd.type === "Q") {
|
|
6166
6429
|
var _13 = 1 / 3;
|
|
6167
6430
|
var _23 = 2 / 3;
|
|
@@ -14562,10 +14825,10 @@ async function writeOverlay(data, track, canvas2, dir) {
|
|
|
14562
14825
|
at = c.end;
|
|
14563
14826
|
}
|
|
14564
14827
|
manifest.push("file blank.png", "option framerate 1000");
|
|
14565
|
-
const
|
|
14566
|
-
await writeFile(
|
|
14828
|
+
const path3 = join3(dir, "subtitles.ffconcat");
|
|
14829
|
+
await writeFile(path3, manifest.join("\n") + "\n");
|
|
14567
14830
|
return {
|
|
14568
|
-
path,
|
|
14831
|
+
path: path3,
|
|
14569
14832
|
cues: result.cues.map(({ start, end }) => ({ start, end })),
|
|
14570
14833
|
width: canvas2.width,
|
|
14571
14834
|
top: Math.round(result.top * canvas2.height / result.height)
|
|
@@ -14596,14 +14859,14 @@ function mixGraph(clips, mix, tracks, trackPaths, duration) {
|
|
|
14596
14859
|
const paths = /* @__PURE__ */ new Map();
|
|
14597
14860
|
const filters = [], voice = [], background = [], other = [];
|
|
14598
14861
|
let count = 0;
|
|
14599
|
-
function place(
|
|
14862
|
+
function place(path3, origin, sourceLength, length, at2, channels, gain2, role, speed, fadeIn = 0, fadeOut = 0) {
|
|
14600
14863
|
if (length <= 0)
|
|
14601
14864
|
mediaError("INVALID_MIX_RANGE", "An audio item falls outside the rendered picture.");
|
|
14602
|
-
let index = paths.get(
|
|
14865
|
+
let index = paths.get(path3);
|
|
14603
14866
|
if (index === void 0) {
|
|
14604
14867
|
index = paths.size;
|
|
14605
|
-
paths.set(
|
|
14606
|
-
args.push("-protocol_whitelist", "file,pipe", "-i",
|
|
14868
|
+
paths.set(path3, index);
|
|
14869
|
+
args.push("-protocol_whitelist", "file,pipe", "-i", path3);
|
|
14607
14870
|
}
|
|
14608
14871
|
const label = "part" + count++;
|
|
14609
14872
|
const chain = [
|
|
@@ -14630,12 +14893,12 @@ function mixGraph(clips, mix, tracks, trackPaths, duration) {
|
|
|
14630
14893
|
bus.push("[" + label + "]");
|
|
14631
14894
|
}
|
|
14632
14895
|
let at = 0;
|
|
14633
|
-
for (const [index, { path, descriptor, timing }] of clips.entries()) {
|
|
14896
|
+
for (const [index, { path: path3, descriptor, timing }] of clips.entries()) {
|
|
14634
14897
|
const original = mix.originals?.find((o) => o.inputIndex === index);
|
|
14635
14898
|
const gain2 = original ? original.gainDb : mix.originalGainDb;
|
|
14636
14899
|
if (descriptor.metadata.hasAudio && gain2 !== null)
|
|
14637
14900
|
place(
|
|
14638
|
-
|
|
14901
|
+
path3,
|
|
14639
14902
|
timing.start,
|
|
14640
14903
|
timing.end - timing.start,
|
|
14641
14904
|
timing.duration,
|
|
@@ -14694,14 +14957,14 @@ function levels(stderr) {
|
|
|
14694
14957
|
mediaError("LOUDNESS_MEASUREMENT_FAILED", "FFmpeg did not return a loudness report.");
|
|
14695
14958
|
return JSON.parse(values[0]);
|
|
14696
14959
|
}
|
|
14697
|
-
async function measureOutput(native, ffmpeg,
|
|
14960
|
+
async function measureOutput(native, ffmpeg, path3, options) {
|
|
14698
14961
|
const result = await native.run(
|
|
14699
14962
|
ffmpeg,
|
|
14700
14963
|
[
|
|
14701
14964
|
"-hide_banner",
|
|
14702
14965
|
"-nostdin",
|
|
14703
14966
|
"-i",
|
|
14704
|
-
|
|
14967
|
+
path3,
|
|
14705
14968
|
"-vn",
|
|
14706
14969
|
"-af",
|
|
14707
14970
|
norm + ":print_format=json",
|
|
@@ -14764,18 +15027,18 @@ async function renderAudio(native, ffmpeg, clips, audio, paths, duration, output
|
|
|
14764
15027
|
);
|
|
14765
15028
|
return output;
|
|
14766
15029
|
}
|
|
14767
|
-
function copyPicture(
|
|
15030
|
+
function copyPicture(path3, start, mixed, profile, output, gainDb = 0) {
|
|
14768
15031
|
return [
|
|
14769
15032
|
"-hide_banner",
|
|
14770
15033
|
"-nostdin",
|
|
14771
15034
|
"-y",
|
|
14772
15035
|
"-copyts",
|
|
14773
|
-
...
|
|
15036
|
+
...path3 ? ["-protocol_whitelist", "file,pipe", "-i", path3] : [],
|
|
14774
15037
|
...mixed ? ["-itsoffset", String(start), "-protocol_whitelist", "file,pipe", "-i", mixed] : [],
|
|
14775
|
-
...
|
|
15038
|
+
...path3 ? ["-map", "0:v:0", "-c:v", "copy"] : ["-vn"],
|
|
14776
15039
|
...mixed ? [
|
|
14777
15040
|
"-map",
|
|
14778
|
-
|
|
15041
|
+
path3 ? "1:a:0" : "0:a:0",
|
|
14779
15042
|
...gainDb ? ["-af", "volume=" + gainDb + "dB"] : [],
|
|
14780
15043
|
"-c:a",
|
|
14781
15044
|
profile.audio === "opus" ? "libopus" : "aac",
|
|
@@ -14958,7 +15221,7 @@ var toolsSchema = z6.object({
|
|
|
14958
15221
|
var snapshot = z6.object({
|
|
14959
15222
|
request: mediaRequest,
|
|
14960
15223
|
audio: audioSnapshot.optional(),
|
|
14961
|
-
descriptors: z6.array(editDescriptor).min(1).max(
|
|
15224
|
+
descriptors: z6.array(editDescriptor).min(1).max(maxSequenceInputs),
|
|
14962
15225
|
tools: toolsSchema
|
|
14963
15226
|
}).strict();
|
|
14964
15227
|
var jobData = z6.object({
|
|
@@ -15161,8 +15424,8 @@ var Jobs = class {
|
|
|
15161
15424
|
await this.videos.restoreMetadata(descriptor, Boolean(audio?.copy));
|
|
15162
15425
|
for (const executable2 of [tools.ffmpeg, tools.ffprobe]) {
|
|
15163
15426
|
try {
|
|
15164
|
-
const { access
|
|
15165
|
-
await
|
|
15427
|
+
const { access } = await import("fs/promises");
|
|
15428
|
+
await access(executable2);
|
|
15166
15429
|
} catch {
|
|
15167
15430
|
mediaError(
|
|
15168
15431
|
"EXECUTION_CONFIG_UNAVAILABLE",
|
|
@@ -15462,10 +15725,10 @@ var Jobs = class {
|
|
|
15462
15725
|
if (audio?.timeline && audio.mix) {
|
|
15463
15726
|
const override = audio.mix.originals?.find((o) => o.inputIndex === index);
|
|
15464
15727
|
const gain2 = override ? override.gainDb : audio.mix.originalGainDb;
|
|
15465
|
-
const
|
|
15728
|
+
const path3 = descriptor.metadata.hasAudio && gain2 !== null ? (await this.videos.restoreMetadata(descriptor, true)).absolutePath : "";
|
|
15466
15729
|
inputs.push({
|
|
15467
15730
|
descriptor,
|
|
15468
|
-
path,
|
|
15731
|
+
path: path3,
|
|
15469
15732
|
timing: { ...audio.timeline[index], frames: [], tolerance: 0 }
|
|
15470
15733
|
});
|
|
15471
15734
|
} else inputs.push(await timedInput(descriptor));
|
|
@@ -15630,9 +15893,9 @@ var Jobs = class {
|
|
|
15630
15893
|
onPrepared: (stagingFileId) => {
|
|
15631
15894
|
row = this.update(id, { stagingFileId });
|
|
15632
15895
|
},
|
|
15633
|
-
probeRunner: (
|
|
15896
|
+
probeRunner: (path3, signal, context) => this.native.run(
|
|
15634
15897
|
d.snapshot.tools.ffprobe,
|
|
15635
|
-
["-v", "error", "-show_format", "-show_streams", "-of", "json",
|
|
15898
|
+
["-v", "error", "-show_format", "-show_streams", "-of", "json", path3],
|
|
15636
15899
|
{ ...commandOptions, directory: context.directory, signal, timeoutMs: 15e3 }
|
|
15637
15900
|
)
|
|
15638
15901
|
}
|
|
@@ -15786,7 +16049,7 @@ var Jobs = class {
|
|
|
15786
16049
|
this.active?.abort.abort();
|
|
15787
16050
|
await this.native.dispose();
|
|
15788
16051
|
if (this.pumping)
|
|
15789
|
-
await Promise.race([this.pumping, new Promise((
|
|
16052
|
+
await Promise.race([this.pumping, new Promise((resolve) => setTimeout(resolve, 6e3))]);
|
|
15790
16053
|
for (const row of this.rows())
|
|
15791
16054
|
if (row.data.state === "queued") {
|
|
15792
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">;
|
|
@@ -747,9 +747,9 @@ declare const exportSettings: z.ZodObject<{
|
|
|
747
747
|
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
748
748
|
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
749
749
|
quality: z.ZodEnum<{
|
|
750
|
+
small: "small";
|
|
750
751
|
high: "high";
|
|
751
752
|
standard: "standard";
|
|
752
|
-
small: "small";
|
|
753
753
|
}>;
|
|
754
754
|
audio: z.ZodBoolean;
|
|
755
755
|
}, z.core.$strict>;
|
|
@@ -817,9 +817,9 @@ declare const processSequence: z.ZodObject<{
|
|
|
817
817
|
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
818
818
|
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
819
819
|
quality: z.ZodEnum<{
|
|
820
|
+
small: "small";
|
|
820
821
|
high: "high";
|
|
821
822
|
standard: "standard";
|
|
822
|
-
small: "small";
|
|
823
823
|
}>;
|
|
824
824
|
audio: z.ZodBoolean;
|
|
825
825
|
}, z.core.$strict>>;
|
|
@@ -970,9 +970,9 @@ declare const mediaRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
970
970
|
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
971
971
|
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
972
972
|
quality: z.ZodEnum<{
|
|
973
|
+
small: "small";
|
|
973
974
|
high: "high";
|
|
974
975
|
standard: "standard";
|
|
975
|
-
small: "small";
|
|
976
976
|
}>;
|
|
977
977
|
audio: z.ZodBoolean;
|
|
978
978
|
}, z.core.$strict>>;
|
|
@@ -1141,9 +1141,9 @@ declare const jobsQuery: z.ZodObject<{
|
|
|
1141
1141
|
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
1142
1142
|
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
1143
1143
|
quality: z.ZodEnum<{
|
|
1144
|
+
small: "small";
|
|
1144
1145
|
high: "high";
|
|
1145
1146
|
standard: "standard";
|
|
1146
|
-
small: "small";
|
|
1147
1147
|
}>;
|
|
1148
1148
|
audio: z.ZodBoolean;
|
|
1149
1149
|
}, z.core.$strict>>;
|
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;
|
|
@@ -12,6 +44,15 @@ var deadline;
|
|
|
12
44
|
var send = (value) => {
|
|
13
45
|
if (process.connected) process.send?.(value);
|
|
14
46
|
};
|
|
47
|
+
async function syncDirectory(directory, platform = process.platform) {
|
|
48
|
+
if (platform === "win32") return;
|
|
49
|
+
const handle = await open(directory, "r");
|
|
50
|
+
try {
|
|
51
|
+
await handle.sync();
|
|
52
|
+
} finally {
|
|
53
|
+
await handle.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
15
56
|
async function record(name, value) {
|
|
16
57
|
if (!active) return;
|
|
17
58
|
const path = join(active.directory, name);
|
|
@@ -24,12 +65,7 @@ async function record(name, value) {
|
|
|
24
65
|
await file.close();
|
|
25
66
|
}
|
|
26
67
|
await rename(temporary, path);
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
await directory.sync();
|
|
30
|
-
} finally {
|
|
31
|
-
await directory.close();
|
|
32
|
-
}
|
|
68
|
+
await syncDirectory(active.directory);
|
|
33
69
|
}
|
|
34
70
|
function stop(code) {
|
|
35
71
|
reason ??= code;
|
|
@@ -97,6 +133,7 @@ process.on("message", async (message) => {
|
|
|
97
133
|
}
|
|
98
134
|
child = spawn(command.command, command.args, {
|
|
99
135
|
shell: false,
|
|
136
|
+
env: scrubChildEnv(process.env),
|
|
100
137
|
stdio: ["ignore", "pipe", "pipe"],
|
|
101
138
|
windowsHide: true
|
|
102
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
|
},
|