@vivix-labs/media-tools 1.0.0-beta → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -9
- package/dist/assets/copy-document-EF4PHM7F.svg +10 -0
- package/dist/assets/crop-5JXWHIPN.svg +6 -0
- package/dist/assets/delete-4Y3OUMEL.svg +8 -0
- package/dist/assets/detail-E52XPONK.svg +4 -0
- package/dist/assets/download-VTKCEAZG.svg +6 -0
- package/dist/assets/edit-JUVJDD5A.svg +6 -0
- package/dist/assets/export-W2OBXZDQ.svg +6 -0
- package/dist/assets/favorite-6GMNHJCN.svg +5 -0
- package/dist/assets/favorite-filled-FR74TEBM.svg +3 -0
- package/dist/assets/filter-JSDZZVGN.svg +5 -0
- package/dist/assets/fullscreen-large-MPLIWDMI.svg +6 -0
- package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
- package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
- package/dist/assets/inter-latin-700-normal-SU5XVJMF.woff2 +0 -0
- package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
- package/dist/assets/mute-large-LSZZ44HF.svg +6 -0
- package/dist/assets/pause-large-XEUBL4KC.svg +6 -0
- package/dist/assets/placeholder-audio-EJEBE7OB.svg +11 -0
- package/dist/assets/placeholder-image-NOVXFVRL.svg +10 -0
- package/dist/assets/placeholder-script-LR2GKWKS.svg +7 -0
- package/dist/assets/placeholder-video-ZFOYHYCR.svg +7 -0
- package/dist/assets/play-cover-WQLOHHPZ.svg +5 -0
- package/dist/assets/playback-play-YRMIX5W4.svg +5 -0
- package/dist/assets/playback-play-large-TM3QUJGG.svg +5 -0
- package/dist/assets/refresh-WQ3CTB57.svg +3 -0
- package/dist/assets/select-items-GJZIVO37.svg +6 -0
- package/dist/assets/trim-LQMHHN2M.svg +9 -0
- package/dist/assets/upload-U5RZT5QI.svg +5 -0
- package/dist/assets/volume-large-QNULSJ2I.svg +6 -0
- package/dist/client.bundle.js +1356 -229
- package/dist/client.css +1585 -138
- package/dist/client.d.ts +1 -0
- package/dist/server.d.ts +2 -1
- package/dist/server.js +182 -41
- package/dist/shared.d.ts +155 -2
- package/dist/shared.js +60 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { VideoEditorProps, VideoCompareProps, MediaJobsProps, MediaRequest, Acce
|
|
|
3
3
|
export { Config } from './shared.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import 'vivix-studio/sdk/shared';
|
|
6
|
+
import '@vivix-labs/ui-system';
|
|
6
7
|
|
|
7
8
|
declare function VideoEditor({ input, mode, onApply, onClose }: VideoEditorProps): React.JSX.Element;
|
|
8
9
|
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ServerContext } from 'vivix-studio/sdk/server';
|
|
2
2
|
import { MediaToolsConfig } from './shared.js';
|
|
3
3
|
export { Config } from './shared.js';
|
|
4
|
-
import 'vivix-studio/sdk/shared';
|
|
5
4
|
import 'react';
|
|
5
|
+
import 'vivix-studio/sdk/shared';
|
|
6
|
+
import '@vivix-labs/ui-system';
|
|
6
7
|
|
|
7
8
|
declare const dependencies: (config: MediaToolsConfig) => string[];
|
|
8
9
|
declare function activate(ctx: ServerContext<MediaToolsConfig>): Promise<void>;
|
package/dist/server.js
CHANGED
|
@@ -3,6 +3,51 @@ import { join as join4 } from "path";
|
|
|
3
3
|
import { defineOperation } from "vivix-studio/sdk/server";
|
|
4
4
|
import { z as z4 } from "vivix-studio/sdk/shared";
|
|
5
5
|
|
|
6
|
+
// packages/media-tools/src/export-settings.ts
|
|
7
|
+
var exportProfiles = {
|
|
8
|
+
h264: {
|
|
9
|
+
label: "MP4 \xB7 H.264",
|
|
10
|
+
extension: "mp4",
|
|
11
|
+
container: "mp4",
|
|
12
|
+
codec: "h264",
|
|
13
|
+
encoder: "libx264",
|
|
14
|
+
audio: "aac",
|
|
15
|
+
crf: [18, 23, 28]
|
|
16
|
+
},
|
|
17
|
+
hevc: {
|
|
18
|
+
label: "MP4 \xB7 H.265",
|
|
19
|
+
extension: "mp4",
|
|
20
|
+
container: "mp4",
|
|
21
|
+
codec: "hevc",
|
|
22
|
+
encoder: "libx265",
|
|
23
|
+
audio: "aac",
|
|
24
|
+
crf: [20, 25, 30]
|
|
25
|
+
},
|
|
26
|
+
vp9: {
|
|
27
|
+
label: "WebM \xB7 VP9",
|
|
28
|
+
extension: "webm",
|
|
29
|
+
container: "webm",
|
|
30
|
+
codec: "vp9",
|
|
31
|
+
encoder: "libvpx-vp9",
|
|
32
|
+
audio: "opus",
|
|
33
|
+
crf: [23, 31, 39]
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var exportAspects = ["source", "16:9", "9:16", "1:1", "4:3", "3:4", "21:9"];
|
|
37
|
+
var exportQualities = ["high", "standard", "small"];
|
|
38
|
+
function exportDimensions(source, aspect, resolution) {
|
|
39
|
+
if (aspect === "source" && resolution === "source") return source;
|
|
40
|
+
const [w = source.width, h = source.height] = aspect === "source" ? [] : aspect.split(":").map(Number);
|
|
41
|
+
const short = resolution === "source" ? Math.min(source.width, source.height) : resolution;
|
|
42
|
+
const even = (n) => 2 * Math.round(n / 2);
|
|
43
|
+
const width = w >= h ? even(short * w / h) : short;
|
|
44
|
+
const height = h >= w ? even(short * h / w) : short;
|
|
45
|
+
return Math.min(width, height) >= 2 && Math.max(width, height) <= 3840 && Math.min(width, height) <= 2160 ? { width, height } : null;
|
|
46
|
+
}
|
|
47
|
+
function exportName(name, extension) {
|
|
48
|
+
return `${name.trim().replace(/\.(mp4|webm)$/i, "").trim()}.${extension}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
6
51
|
// packages/media-tools/src/shared.ts
|
|
7
52
|
import { z, PluginError } from "vivix-studio/sdk/shared";
|
|
8
53
|
var packageVersion = "0.1.22-ecommerce.20261110.1";
|
|
@@ -80,10 +125,35 @@ var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.numb
|
|
|
80
125
|
(v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
|
|
81
126
|
"Canvas dimensions must be even and within 3840 by 2160."
|
|
82
127
|
);
|
|
128
|
+
var exportFormat = z.enum(
|
|
129
|
+
Object.keys(exportProfiles)
|
|
130
|
+
);
|
|
131
|
+
var exportSettings = z.object({
|
|
132
|
+
format: exportFormat,
|
|
133
|
+
aspect: z.enum(exportAspects),
|
|
134
|
+
resolution: z.union([
|
|
135
|
+
z.literal("source"),
|
|
136
|
+
z.literal(480),
|
|
137
|
+
z.literal(720),
|
|
138
|
+
z.literal(1080),
|
|
139
|
+
z.literal(2160)
|
|
140
|
+
]),
|
|
141
|
+
frameRate: z.union([
|
|
142
|
+
z.literal("source"),
|
|
143
|
+
z.literal(24),
|
|
144
|
+
z.literal(25),
|
|
145
|
+
z.literal(30),
|
|
146
|
+
z.literal(50),
|
|
147
|
+
z.literal(60)
|
|
148
|
+
]),
|
|
149
|
+
quality: z.enum(exportQualities),
|
|
150
|
+
audio: z.boolean()
|
|
151
|
+
}).strict();
|
|
83
152
|
var processSequence = z.object({
|
|
84
153
|
inputs: z.array(sequenceVideoInput).min(1).max(64),
|
|
85
154
|
outputName,
|
|
86
155
|
canvas,
|
|
156
|
+
settings: exportSettings.optional(),
|
|
87
157
|
retryOfJobId: z.uuid().optional()
|
|
88
158
|
}).strict();
|
|
89
159
|
var mediaRequest = z.discriminatedUnion("operation", [
|
|
@@ -460,13 +530,19 @@ function fraction(value) {
|
|
|
460
530
|
const [a, b] = String(value).split("/").map(Number);
|
|
461
531
|
return b ? a / b : a;
|
|
462
532
|
}
|
|
463
|
-
function parseMetadata(info, file) {
|
|
533
|
+
function parseMetadata(info, file, output) {
|
|
464
534
|
const streams = info.streams || [], videos = streams.filter((v) => v.codec_type === "video"), audios = streams.filter((v) => v.codec_type === "audio");
|
|
465
535
|
if (videos.length !== 1 || audios.length > 1 || streams.some((v) => !["video", "audio"].includes(v.codec_type)))
|
|
466
|
-
mediaError(
|
|
536
|
+
mediaError(
|
|
537
|
+
"UNSUPPORTED_MEDIA",
|
|
538
|
+
output ? "The exported stream layout is invalid." : "Use one H.264 video stream and at most one AAC audio stream."
|
|
539
|
+
);
|
|
467
540
|
const video = videos[0], audio = audios[0], audioSampleRate = audio ? Number(audio.sample_rate) : null;
|
|
468
|
-
if (!String(info.format?.format_name).split(",").includes("mp4") || video.codec_name !== "h264" || video.pix_fmt !== "yuv420p" || !["1:1", "N/A", void 0].includes(video.sample_aspect_ratio))
|
|
469
|
-
mediaError(
|
|
541
|
+
if (!String(info.format?.format_name).split(",").includes(output?.container ?? "mp4") || video.codec_name !== (output?.codec ?? "h264") || video.pix_fmt !== "yuv420p" || !["1:1", "N/A", void 0].includes(video.sample_aspect_ratio))
|
|
542
|
+
mediaError(
|
|
543
|
+
"UNSUPPORTED_MEDIA",
|
|
544
|
+
output ? "The exported video does not match the selected format." : "Use an 8-bit square-pixel H.264 MP4 video."
|
|
545
|
+
);
|
|
470
546
|
const colorTags = [video.color_space, video.color_transfer, video.color_primaries];
|
|
471
547
|
const missingColor = (tag) => tag === void 0 || tag === null || ["", "unknown", "unspecified", "N/A"].includes(String(tag));
|
|
472
548
|
const declaredHdr = video.side_data_list?.some(
|
|
@@ -497,8 +573,11 @@ function parseMetadata(info, file) {
|
|
|
497
573
|
"MEDIA_LIMIT_EXCEEDED",
|
|
498
574
|
"Use an even-sized video up to 3840 by 2160, 60 fps, 600 seconds and 2 GiB."
|
|
499
575
|
);
|
|
500
|
-
if (audio && (audio.codec_name !== "aac" || ![1, 2].includes(audio.channels) || audioSampleRate === null || !Number.isInteger(audioSampleRate) || audioSampleRate <= 0 || !["mono", "stereo"].includes(audio.channel_layout)))
|
|
501
|
-
mediaError(
|
|
576
|
+
if (audio && (audio.codec_name !== (output?.audio ?? "aac") || ![1, 2].includes(audio.channels) || audioSampleRate === null || !Number.isInteger(audioSampleRate) || audioSampleRate <= 0 || !["mono", "stereo"].includes(audio.channel_layout)))
|
|
577
|
+
mediaError(
|
|
578
|
+
"UNSUPPORTED_AUDIO",
|
|
579
|
+
output ? "The exported audio does not match the selected format." : "Use one mono or stereo AAC track with a valid sample rate."
|
|
580
|
+
);
|
|
502
581
|
return metadata.parse({
|
|
503
582
|
durationMs: Math.round(duration * 1e3),
|
|
504
583
|
width,
|
|
@@ -589,15 +668,31 @@ var Videos = class {
|
|
|
589
668
|
if (!/\blibx264\b/.test(encoders) || !/\baac\b/.test(encoders))
|
|
590
669
|
mediaError("TOOL_UNSUPPORTED", "FFmpeg needs libx264 and AAC encoders.");
|
|
591
670
|
const filters = (await this.command(ffmpeg, ["-hide_banner", "-filters"])).stdout;
|
|
592
|
-
for (const filter of [
|
|
671
|
+
for (const filter of [
|
|
672
|
+
"trim",
|
|
673
|
+
"atrim",
|
|
674
|
+
"crop",
|
|
675
|
+
"scale",
|
|
676
|
+
"concat",
|
|
677
|
+
"aresample",
|
|
678
|
+
"anullsrc",
|
|
679
|
+
"fps",
|
|
680
|
+
"pad"
|
|
681
|
+
])
|
|
593
682
|
if (!new RegExp("\\b" + filter + "\\b").test(filters))
|
|
594
683
|
mediaError("TOOL_UNSUPPORTED", "FFmpeg is missing required video or audio filters.");
|
|
684
|
+
const muxers = (await this.command(ffmpeg, ["-hide_banner", "-muxers"])).stdout;
|
|
685
|
+
const exportFormats = ["h264"];
|
|
686
|
+
if (/\bmp4\b/.test(muxers) && /\blibx265\b/.test(encoders)) exportFormats.push("hevc");
|
|
687
|
+
if (/\bwebm\b/.test(muxers) && /\blibvpx-vp9\b/.test(encoders) && /\blibopus\b/.test(encoders))
|
|
688
|
+
exportFormats.push("vp9");
|
|
595
689
|
this.toolCache = {
|
|
596
690
|
ffmpeg,
|
|
597
691
|
ffprobe,
|
|
598
692
|
ffmpegVersion: encoder.stdout.split("\n")[0],
|
|
599
693
|
ffprobeVersion: probe.stdout.split("\n")[0],
|
|
600
|
-
profileVersion: 1
|
|
694
|
+
profileVersion: 1,
|
|
695
|
+
exportFormats
|
|
601
696
|
};
|
|
602
697
|
return this.toolCache;
|
|
603
698
|
}
|
|
@@ -862,8 +957,10 @@ function segmentTiming(descriptor, frames) {
|
|
|
862
957
|
};
|
|
863
958
|
}
|
|
864
959
|
var seconds = (value) => Number(value.toFixed(9)).toString();
|
|
865
|
-
function renderArguments(inputs, output, canvas2) {
|
|
866
|
-
const
|
|
960
|
+
function renderArguments(inputs, output, canvas2, settings) {
|
|
961
|
+
const profile = exportProfiles[settings?.format ?? "h264"];
|
|
962
|
+
const fps = typeof settings?.frameRate === "number" ? settings.frameRate : void 0;
|
|
963
|
+
const audible = settings?.audio !== false && inputs.some((i) => i.descriptor.metadata.hasAudio), sequence = Boolean(canvas2), sourceRate = inputs[0]?.descriptor.metadata.audioSampleRate ?? null, audioSampleRate = audible ? sequence || sourceRate === 32e3 ? 48e3 : sourceRate : null, filters = [], labels = [];
|
|
867
964
|
const args = ["-hide_banner", "-nostdin", "-y", "-copyts"];
|
|
868
965
|
for (const input of inputs) args.push("-protocol_whitelist", "file,pipe", "-i", input.path);
|
|
869
966
|
for (const [index, { descriptor, timing }] of inputs.entries()) {
|
|
@@ -875,7 +972,8 @@ function renderArguments(inputs, output, canvas2) {
|
|
|
875
972
|
`crop=${rect.width}:${rect.height}:${rect.x}:${rect.y}`,
|
|
876
973
|
"setsar=1",
|
|
877
974
|
...canvas2 ? [
|
|
878
|
-
`scale=${canvas2.width}:${canvas2.height}:flags=lanczos:in_color_matrix=bt709:out_color_matrix=bt709
|
|
975
|
+
`scale=${canvas2.width}:${canvas2.height}:flags=lanczos:in_color_matrix=bt709:out_color_matrix=bt709${settings ? ":force_original_aspect_ratio=decrease:force_divisible_by=2" : ""}`,
|
|
976
|
+
...settings ? [`pad=${canvas2.width}:${canvas2.height}:(ow-iw)/2:(oh-ih)/2:black`, "setsar=1"] : []
|
|
879
977
|
] : [],
|
|
880
978
|
"format=yuv420p",
|
|
881
979
|
"setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709"
|
|
@@ -899,17 +997,28 @@ function renderArguments(inputs, output, canvas2) {
|
|
|
899
997
|
labels.join("") + `concat=n=${inputs.length}:v=1:a=${audible ? 1 : 0}[video]${audible ? "[audio]" : ""}`
|
|
900
998
|
);
|
|
901
999
|
}
|
|
902
|
-
|
|
1000
|
+
const videoLabel = inputs.length > 1 ? "[video]" : "[v0]";
|
|
1001
|
+
if (fps) {
|
|
1002
|
+
filters.push(`${videoLabel}fps=fps=${fps}:start_time=0:eof_action=pass[cfr]`);
|
|
1003
|
+
}
|
|
1004
|
+
args.push("-filter_complex", filters.join(";"), "-map", fps ? "[cfr]" : videoLabel);
|
|
903
1005
|
if (audible)
|
|
904
|
-
args.push(
|
|
1006
|
+
args.push(
|
|
1007
|
+
"-map",
|
|
1008
|
+
inputs.length > 1 ? "[audio]" : "[a0]",
|
|
1009
|
+
"-c:a",
|
|
1010
|
+
profile.audio === "opus" ? "libopus" : profile.audio,
|
|
1011
|
+
"-b:a",
|
|
1012
|
+
"192k"
|
|
1013
|
+
);
|
|
905
1014
|
else args.push("-an");
|
|
906
1015
|
args.push(
|
|
907
1016
|
"-c:v",
|
|
908
|
-
|
|
1017
|
+
profile.encoder,
|
|
909
1018
|
"-crf",
|
|
910
|
-
"
|
|
911
|
-
"-preset",
|
|
912
|
-
"
|
|
1019
|
+
String(profile.crf[exportQualities.indexOf(settings?.quality ?? "high")]),
|
|
1020
|
+
...profile.codec === "vp9" ? ["-b:v", "0", "-deadline", "good", "-cpu-used", "2"] : ["-preset", "medium"],
|
|
1021
|
+
...profile.codec === "hevc" ? ["-tag:v", "hvc1", "-x265-params", "pools=4"] : [],
|
|
913
1022
|
"-threads",
|
|
914
1023
|
"4",
|
|
915
1024
|
"-pix_fmt",
|
|
@@ -917,9 +1026,11 @@ function renderArguments(inputs, output, canvas2) {
|
|
|
917
1026
|
"-fps_mode",
|
|
918
1027
|
"passthrough",
|
|
919
1028
|
"-enc_time_base:v",
|
|
920
|
-
"1:90000",
|
|
921
|
-
"-video_track_timescale",
|
|
922
|
-
|
|
1029
|
+
fps ? `1:${fps}` : "1:90000",
|
|
1030
|
+
...profile.container === "mp4" ? ["-video_track_timescale", "90000", "-movflags", "+faststart"] : (
|
|
1031
|
+
// Older WebM muxers otherwise move all video timestamps to offset Opus pre-roll.
|
|
1032
|
+
["-avoid_negative_ts", "disabled"]
|
|
1033
|
+
),
|
|
923
1034
|
"-color_primaries",
|
|
924
1035
|
"bt709",
|
|
925
1036
|
"-color_trc",
|
|
@@ -928,8 +1039,6 @@ function renderArguments(inputs, output, canvas2) {
|
|
|
928
1039
|
"bt709",
|
|
929
1040
|
"-metadata:s:v:0",
|
|
930
1041
|
"rotate=0",
|
|
931
|
-
"-movflags",
|
|
932
|
-
"+faststart",
|
|
933
1042
|
"-progress",
|
|
934
1043
|
"pipe:1",
|
|
935
1044
|
"-stats_period",
|
|
@@ -948,7 +1057,13 @@ function renderArguments(inputs, output, canvas2) {
|
|
|
948
1057
|
tolerance: inputs.reduce((n, i) => n + i.timing.tolerance, 0)
|
|
949
1058
|
};
|
|
950
1059
|
}
|
|
951
|
-
function validateFrameTiming(actual, timings) {
|
|
1060
|
+
function validateFrameTiming(actual, timings, fps, webm = false) {
|
|
1061
|
+
const precision = webm ? 2e-3 : 1e-3;
|
|
1062
|
+
if (fps) {
|
|
1063
|
+
if (actual.some((pts, index2) => Math.abs(pts - actual[0] - index2 / fps) > precision))
|
|
1064
|
+
mediaError("OUTPUT_TIMING_MISMATCH", "The output does not have the selected frame cadence.");
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
952
1067
|
if (actual.length !== timings.reduce((total, timing) => total + timing.frames.length, 0))
|
|
953
1068
|
mediaError("OUTPUT_TIMING_MISMATCH", "The output frame count changed.");
|
|
954
1069
|
let index = 0, expectedStart = 0, boundaryTolerance = 0;
|
|
@@ -960,7 +1075,7 @@ function validateFrameTiming(actual, timings) {
|
|
|
960
1075
|
"The output segment boundary moved beyond the source frame allowance."
|
|
961
1076
|
);
|
|
962
1077
|
for (let offset = 0; offset < timing.frames.length; offset++)
|
|
963
|
-
if (Math.abs(actual[index + offset] - first - timing.frames[offset]) >
|
|
1078
|
+
if (Math.abs(actual[index + offset] - first - timing.frames[offset]) > precision)
|
|
964
1079
|
mediaError("OUTPUT_TIMING_MISMATCH", "The output changed timing inside a source segment.");
|
|
965
1080
|
index += timing.frames.length;
|
|
966
1081
|
expectedStart += timing.duration;
|
|
@@ -974,7 +1089,8 @@ var toolsSchema = z3.object({
|
|
|
974
1089
|
ffprobe: z3.string(),
|
|
975
1090
|
ffmpegVersion: z3.string(),
|
|
976
1091
|
ffprobeVersion: z3.string(),
|
|
977
|
-
profileVersion: z3.literal(1)
|
|
1092
|
+
profileVersion: z3.literal(1),
|
|
1093
|
+
exportFormats: z3.array(exportFormat).optional()
|
|
978
1094
|
}).strict();
|
|
979
1095
|
var snapshot = z3.object({
|
|
980
1096
|
request: mediaRequest,
|
|
@@ -1191,10 +1307,23 @@ var Jobs = class {
|
|
|
1191
1307
|
}
|
|
1192
1308
|
if (request.operation === "sequence.process") {
|
|
1193
1309
|
const canvas2 = request.input.canvas, bytes = /* @__PURE__ */ new Map();
|
|
1310
|
+
const settings = request.input.settings;
|
|
1311
|
+
if (settings) {
|
|
1312
|
+
if (!(tools.exportFormats ?? ["h264"]).includes(settings.format))
|
|
1313
|
+
mediaError(
|
|
1314
|
+
"TOOL_UNSUPPORTED",
|
|
1315
|
+
"The configured FFmpeg cannot export the selected format."
|
|
1316
|
+
);
|
|
1317
|
+
if (!exportDimensions(canvas2, settings.aspect, settings.resolution))
|
|
1318
|
+
mediaError(
|
|
1319
|
+
"MEDIA_LIMIT_EXCEEDED",
|
|
1320
|
+
"The selected aspect ratio and resolution exceed 3840 by 2160."
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1194
1323
|
let duration = 0;
|
|
1195
1324
|
for (const d of descriptors) {
|
|
1196
1325
|
const rect = d.geometry.pixelRect;
|
|
1197
|
-
if (rect.width * canvas2.height !== rect.height * canvas2.width)
|
|
1326
|
+
if (!settings && rect.width * canvas2.height !== rect.height * canvas2.width)
|
|
1198
1327
|
mediaError(
|
|
1199
1328
|
"SEQUENCE_GEOMETRY_MISMATCH",
|
|
1200
1329
|
"Every selected crop must have exactly the project output aspect ratio."
|
|
@@ -1377,7 +1506,13 @@ var Jobs = class {
|
|
|
1377
1506
|
);
|
|
1378
1507
|
const d = row.data, directory = this.directory(id, token);
|
|
1379
1508
|
await mkdir2(directory, { recursive: true });
|
|
1380
|
-
|
|
1509
|
+
const sequence = d.snapshot.request.operation === "sequence.process" ? d.snapshot.request.input : void 0;
|
|
1510
|
+
const settings = sequence?.settings;
|
|
1511
|
+
const targetCanvas = sequence && (settings ? exportDimensions(sequence.canvas, settings.aspect, settings.resolution) : sequence.canvas);
|
|
1512
|
+
if (targetCanvas === null)
|
|
1513
|
+
mediaError("MEDIA_LIMIT_EXCEEDED", "The selected output size is unavailable.");
|
|
1514
|
+
const profile = exportProfiles[settings?.format ?? "h264"];
|
|
1515
|
+
output = join3(directory, `output.${profile.extension}`);
|
|
1381
1516
|
const space = await statfs(directory);
|
|
1382
1517
|
if (Number(space.bavail) * Number(space.bsize) < 4.5 * 1024 ** 3)
|
|
1383
1518
|
mediaError(
|
|
@@ -1415,11 +1550,7 @@ var Jobs = class {
|
|
|
1415
1550
|
timing: segmentTiming(descriptor, frames)
|
|
1416
1551
|
});
|
|
1417
1552
|
}
|
|
1418
|
-
const rendered = renderArguments(
|
|
1419
|
-
inputs,
|
|
1420
|
-
output,
|
|
1421
|
-
d.snapshot.request.operation === "sequence.process" ? d.snapshot.request.input.canvas : void 0
|
|
1422
|
-
);
|
|
1553
|
+
const rendered = renderArguments(inputs, output, targetCanvas, settings);
|
|
1423
1554
|
let progressBuffer = "", lastProgress = 0;
|
|
1424
1555
|
await this.native.run(d.snapshot.tools.ffmpeg, rendered.args, {
|
|
1425
1556
|
...commandOptions,
|
|
@@ -1460,12 +1591,17 @@ var Jobs = class {
|
|
|
1460
1591
|
const hash = createHash2("sha256");
|
|
1461
1592
|
for await (const chunk of createReadStream(output, { signal: abort.signal }))
|
|
1462
1593
|
hash.update(chunk);
|
|
1463
|
-
const checked = parseMetadata(
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1594
|
+
const checked = parseMetadata(
|
|
1595
|
+
JSON.parse(details.stdout),
|
|
1596
|
+
{
|
|
1597
|
+
sizeBytes: size,
|
|
1598
|
+
sha256: hash.digest("hex")
|
|
1599
|
+
},
|
|
1600
|
+
settings ? profile : void 0
|
|
1601
|
+
);
|
|
1602
|
+
const target = targetCanvas ?? inputs[0].descriptor.geometry.pixelRect;
|
|
1603
|
+
const fps = typeof settings?.frameRate === "number" ? settings.frameRate : void 0;
|
|
1604
|
+
if (checked.colorInterpretation !== "declared-bt709" || checked.displayWidth !== target.width || checked.displayHeight !== target.height || checked.hasAudio !== rendered.audible || checked.audioSampleRate !== rendered.audioSampleRate || Math.abs(checked.durationMs / 1e3 - rendered.duration) > rendered.tolerance + 1024 / 48e3 + (fps ? 1 / fps : 0))
|
|
1469
1605
|
mediaError(
|
|
1470
1606
|
"OUTPUT_VALIDATION_FAILED",
|
|
1471
1607
|
"The output color declaration, geometry, duration or audio does not match the fixed recipe."
|
|
@@ -1488,7 +1624,9 @@ var Jobs = class {
|
|
|
1488
1624
|
const actualFrames = frameTimes(frameResult.stdout);
|
|
1489
1625
|
validateFrameTiming(
|
|
1490
1626
|
actualFrames,
|
|
1491
|
-
inputs.map((input) => input.timing)
|
|
1627
|
+
inputs.map((input) => input.timing),
|
|
1628
|
+
fps,
|
|
1629
|
+
profile.container === "webm"
|
|
1492
1630
|
);
|
|
1493
1631
|
const decoded = await this.native.run(
|
|
1494
1632
|
d.snapshot.tools.ffmpeg,
|
|
@@ -1502,7 +1640,7 @@ var Jobs = class {
|
|
|
1502
1640
|
mediaError("OUTPUT_DECODE_FAILED", "The result could not be completely decoded.");
|
|
1503
1641
|
const staged = await this.data.stage(
|
|
1504
1642
|
createReadStream(output),
|
|
1505
|
-
d.snapshot.request.input.outputName + ".mp4",
|
|
1643
|
+
settings ? exportName(d.snapshot.request.input.outputName, profile.extension) : d.snapshot.request.input.outputName + ".mp4",
|
|
1506
1644
|
"local",
|
|
1507
1645
|
{
|
|
1508
1646
|
signal: abort.signal,
|
|
@@ -1536,7 +1674,7 @@ var Jobs = class {
|
|
|
1536
1674
|
kind: d.kind,
|
|
1537
1675
|
jobId: id,
|
|
1538
1676
|
inputs: ordered,
|
|
1539
|
-
canvas:
|
|
1677
|
+
canvas: targetCanvas ?? null,
|
|
1540
1678
|
tools: {
|
|
1541
1679
|
ffmpegVersion: d.snapshot.tools.ffmpegVersion,
|
|
1542
1680
|
ffprobeVersion: d.snapshot.tools.ffprobeVersion,
|
|
@@ -1705,6 +1843,9 @@ async function activate(ctx) {
|
|
|
1705
1843
|
return action(input, { ...call, scope: data.scope });
|
|
1706
1844
|
}
|
|
1707
1845
|
);
|
|
1846
|
+
handle("export.capabilities", z4.object({}).strict(), async () => ({
|
|
1847
|
+
formats: (await videos.tools()).exportFormats ?? ["h264"]
|
|
1848
|
+
}));
|
|
1708
1849
|
handle("video.resolve", videoInput, (input) => videos.resolve(input));
|
|
1709
1850
|
handle("edits.get", z4.object({ editRef: versionRef }).strict(), async (input) => {
|
|
1710
1851
|
const saved = edits.get(input.editRef);
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { CallContext as CallContext$1, z } from 'vivix-studio/sdk/shared';
|
|
4
|
+
import { MenuItem } from '@vivix-labs/ui-system';
|
|
3
5
|
|
|
4
6
|
type Scope = {
|
|
5
7
|
kind: 'user' | 'project';
|
|
@@ -77,6 +79,17 @@ interface StagedFile {
|
|
|
77
79
|
originalName: string;
|
|
78
80
|
details: Record<string, any>;
|
|
79
81
|
}
|
|
82
|
+
interface UploadChunk {
|
|
83
|
+
uploadId: string;
|
|
84
|
+
originalName: string;
|
|
85
|
+
totalBytes: number;
|
|
86
|
+
offset: number;
|
|
87
|
+
bytes: Uint8Array;
|
|
88
|
+
}
|
|
89
|
+
interface UploadProgress {
|
|
90
|
+
nextOffset: number;
|
|
91
|
+
staged?: StagedFile;
|
|
92
|
+
}
|
|
80
93
|
type SqlScalar = null | string | number;
|
|
81
94
|
interface SqlInput {
|
|
82
95
|
sql: string;
|
|
@@ -132,6 +145,14 @@ interface Transaction {
|
|
|
132
145
|
removeRelations(sourceObjectId: string, kind: 'reference'): void;
|
|
133
146
|
relation(sourceObjectId: string, sourceVersionId: string | null, target: VersionRef, kind: 'source' | 'input' | 'reference'): void;
|
|
134
147
|
}
|
|
148
|
+
/** Bytes supplied by an installed plugin, with build-time media metadata and digest. */
|
|
149
|
+
interface BundledFile {
|
|
150
|
+
fileId: string;
|
|
151
|
+
originalName: string;
|
|
152
|
+
mimeType: string;
|
|
153
|
+
sha256: string;
|
|
154
|
+
bytes: Uint8Array;
|
|
155
|
+
}
|
|
135
156
|
interface DataAPI {
|
|
136
157
|
readonly storeId: string;
|
|
137
158
|
readonly scope: Scope;
|
|
@@ -140,6 +161,7 @@ interface DataAPI {
|
|
|
140
161
|
items: RecordValue[];
|
|
141
162
|
nextOffset: number | null;
|
|
142
163
|
};
|
|
164
|
+
countVersionedRecords?(typeId: string): number;
|
|
143
165
|
query(input: SqlInput): Promise<SqlRow[]>;
|
|
144
166
|
mutate(input: MutationInput, call: CallContext): Promise<MutationResult>;
|
|
145
167
|
versions(id: string): VersionValue[];
|
|
@@ -159,7 +181,10 @@ interface DataAPI {
|
|
|
159
181
|
observedCount: number;
|
|
160
182
|
}[];
|
|
161
183
|
stage(source: AsyncIterable<Uint8Array>, originalName: string, actorId: string, options?: StageOptions): Promise<StagedFile>;
|
|
184
|
+
prepareBundledFiles(operationId: string, files: BundledFile[]): Promise<FileValue[]>;
|
|
162
185
|
stageText(text: string, actorId: string): Promise<StagedFile>;
|
|
186
|
+
/** Bounded JSON transport into the existing staging area; does not publish a version. */
|
|
187
|
+
stageChunk(input: UploadChunk, actorId: string): Promise<UploadProgress>;
|
|
163
188
|
publish(stagingIds: string[], objectId: string, versionId: string, operationId: string, actorId: string, fileRoles?: string[]): Promise<{
|
|
164
189
|
files: FileValue[];
|
|
165
190
|
details: any;
|
|
@@ -430,6 +455,36 @@ declare const canvas: z.ZodObject<{
|
|
|
430
455
|
width: z.ZodNumber;
|
|
431
456
|
height: z.ZodNumber;
|
|
432
457
|
}, z.core.$strict>;
|
|
458
|
+
declare const exportFormat: z.ZodEnum<{
|
|
459
|
+
h264: "h264";
|
|
460
|
+
hevc: "hevc";
|
|
461
|
+
vp9: "vp9";
|
|
462
|
+
}>;
|
|
463
|
+
declare const exportSettings: z.ZodObject<{
|
|
464
|
+
format: z.ZodEnum<{
|
|
465
|
+
h264: "h264";
|
|
466
|
+
hevc: "hevc";
|
|
467
|
+
vp9: "vp9";
|
|
468
|
+
}>;
|
|
469
|
+
aspect: z.ZodEnum<{
|
|
470
|
+
source: "source";
|
|
471
|
+
"16:9": "16:9";
|
|
472
|
+
"9:16": "9:16";
|
|
473
|
+
"1:1": "1:1";
|
|
474
|
+
"4:3": "4:3";
|
|
475
|
+
"3:4": "3:4";
|
|
476
|
+
"21:9": "21:9";
|
|
477
|
+
}>;
|
|
478
|
+
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
479
|
+
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
480
|
+
quality: z.ZodEnum<{
|
|
481
|
+
high: "high";
|
|
482
|
+
standard: "standard";
|
|
483
|
+
small: "small";
|
|
484
|
+
}>;
|
|
485
|
+
audio: z.ZodBoolean;
|
|
486
|
+
}, z.core.$strict>;
|
|
487
|
+
type ExportSettings = z.infer<typeof exportSettings>;
|
|
433
488
|
declare const processSequence: z.ZodObject<{
|
|
434
489
|
inputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
435
490
|
kind: z.ZodLiteral<"source">;
|
|
@@ -455,6 +510,30 @@ declare const processSequence: z.ZodObject<{
|
|
|
455
510
|
width: z.ZodNumber;
|
|
456
511
|
height: z.ZodNumber;
|
|
457
512
|
}, z.core.$strict>;
|
|
513
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
514
|
+
format: z.ZodEnum<{
|
|
515
|
+
h264: "h264";
|
|
516
|
+
hevc: "hevc";
|
|
517
|
+
vp9: "vp9";
|
|
518
|
+
}>;
|
|
519
|
+
aspect: z.ZodEnum<{
|
|
520
|
+
source: "source";
|
|
521
|
+
"16:9": "16:9";
|
|
522
|
+
"9:16": "9:16";
|
|
523
|
+
"1:1": "1:1";
|
|
524
|
+
"4:3": "4:3";
|
|
525
|
+
"3:4": "3:4";
|
|
526
|
+
"21:9": "21:9";
|
|
527
|
+
}>;
|
|
528
|
+
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
529
|
+
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
530
|
+
quality: z.ZodEnum<{
|
|
531
|
+
high: "high";
|
|
532
|
+
standard: "standard";
|
|
533
|
+
small: "small";
|
|
534
|
+
}>;
|
|
535
|
+
audio: z.ZodBoolean;
|
|
536
|
+
}, z.core.$strict>>;
|
|
458
537
|
retryOfJobId: z.ZodOptional<z.ZodUUID>;
|
|
459
538
|
}, z.core.$strict>;
|
|
460
539
|
type ProcessVideo = z.infer<typeof processVideo>;
|
|
@@ -517,6 +596,30 @@ declare const mediaRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
517
596
|
width: z.ZodNumber;
|
|
518
597
|
height: z.ZodNumber;
|
|
519
598
|
}, z.core.$strict>;
|
|
599
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
600
|
+
format: z.ZodEnum<{
|
|
601
|
+
h264: "h264";
|
|
602
|
+
hevc: "hevc";
|
|
603
|
+
vp9: "vp9";
|
|
604
|
+
}>;
|
|
605
|
+
aspect: z.ZodEnum<{
|
|
606
|
+
source: "source";
|
|
607
|
+
"16:9": "16:9";
|
|
608
|
+
"9:16": "9:16";
|
|
609
|
+
"1:1": "1:1";
|
|
610
|
+
"4:3": "4:3";
|
|
611
|
+
"3:4": "3:4";
|
|
612
|
+
"21:9": "21:9";
|
|
613
|
+
}>;
|
|
614
|
+
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
615
|
+
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
616
|
+
quality: z.ZodEnum<{
|
|
617
|
+
high: "high";
|
|
618
|
+
standard: "standard";
|
|
619
|
+
small: "small";
|
|
620
|
+
}>;
|
|
621
|
+
audio: z.ZodBoolean;
|
|
622
|
+
}, z.core.$strict>>;
|
|
520
623
|
retryOfJobId: z.ZodOptional<z.ZodUUID>;
|
|
521
624
|
}, z.core.$strict>;
|
|
522
625
|
}, z.core.$strict>], "operation">;
|
|
@@ -597,6 +700,30 @@ declare const jobsQuery: z.ZodObject<{
|
|
|
597
700
|
width: z.ZodNumber;
|
|
598
701
|
height: z.ZodNumber;
|
|
599
702
|
}, z.core.$strict>;
|
|
703
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
704
|
+
format: z.ZodEnum<{
|
|
705
|
+
h264: "h264";
|
|
706
|
+
hevc: "hevc";
|
|
707
|
+
vp9: "vp9";
|
|
708
|
+
}>;
|
|
709
|
+
aspect: z.ZodEnum<{
|
|
710
|
+
source: "source";
|
|
711
|
+
"16:9": "16:9";
|
|
712
|
+
"9:16": "9:16";
|
|
713
|
+
"1:1": "1:1";
|
|
714
|
+
"4:3": "4:3";
|
|
715
|
+
"3:4": "3:4";
|
|
716
|
+
"21:9": "21:9";
|
|
717
|
+
}>;
|
|
718
|
+
resolution: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<480>, z.ZodLiteral<720>, z.ZodLiteral<1080>, z.ZodLiteral<2160>]>;
|
|
719
|
+
frameRate: z.ZodUnion<readonly [z.ZodLiteral<"source">, z.ZodLiteral<24>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>, z.ZodLiteral<60>]>;
|
|
720
|
+
quality: z.ZodEnum<{
|
|
721
|
+
high: "high";
|
|
722
|
+
standard: "standard";
|
|
723
|
+
small: "small";
|
|
724
|
+
}>;
|
|
725
|
+
audio: z.ZodBoolean;
|
|
726
|
+
}, z.core.$strict>>;
|
|
600
727
|
retryOfJobId: z.ZodOptional<z.ZodUUID>;
|
|
601
728
|
}, z.core.$strict>]>;
|
|
602
729
|
}, z.core.$strict>>;
|
|
@@ -605,6 +732,27 @@ interface JobPage {
|
|
|
605
732
|
items: MediaJob[];
|
|
606
733
|
nextOffset: number | null;
|
|
607
734
|
}
|
|
735
|
+
interface VideoExportProps {
|
|
736
|
+
title: string;
|
|
737
|
+
preview: React.ReactNode;
|
|
738
|
+
aspectRatio?: string;
|
|
739
|
+
canvas?: ProcessSequence['canvas'];
|
|
740
|
+
issue?: string;
|
|
741
|
+
legacyTracking?: {
|
|
742
|
+
jobId?: string;
|
|
743
|
+
pending?: {
|
|
744
|
+
key: string;
|
|
745
|
+
request: MediaRequest;
|
|
746
|
+
};
|
|
747
|
+
recoverIntent?(): Promise<{
|
|
748
|
+
key: string;
|
|
749
|
+
request: MediaRequest;
|
|
750
|
+
}>;
|
|
751
|
+
};
|
|
752
|
+
prepare(): Promise<Omit<ProcessSequence, 'outputName'>>;
|
|
753
|
+
resolveDownload(result: VideoFileRef): Promise<string | null | undefined>;
|
|
754
|
+
onClose(): void;
|
|
755
|
+
}
|
|
608
756
|
interface VideoEditorProps {
|
|
609
757
|
input: VideoInput;
|
|
610
758
|
mode: 'crop' | 'trim';
|
|
@@ -616,6 +764,7 @@ interface CompareSlot {
|
|
|
616
764
|
input: VideoInput | null;
|
|
617
765
|
context?: {
|
|
618
766
|
shotName?: string;
|
|
767
|
+
spokenLine?: string;
|
|
619
768
|
hook?: string;
|
|
620
769
|
cta?: string;
|
|
621
770
|
};
|
|
@@ -628,12 +777,16 @@ interface VideoCompareProps {
|
|
|
628
777
|
label: string;
|
|
629
778
|
input: VideoInput;
|
|
630
779
|
context?: CompareSlot['context'];
|
|
780
|
+
preview?: ReactNode;
|
|
631
781
|
}[];
|
|
782
|
+
/** Allow an occupied candidate to exchange places with the target column. */
|
|
783
|
+
allowCandidateSwap?: boolean;
|
|
632
784
|
onRequestReplacement?(slotId: string): Promise<VideoInput | null>;
|
|
633
785
|
onOpenDetails(input: VideoInput, back: {
|
|
634
786
|
slots: CompareSlot[];
|
|
635
787
|
origin: string;
|
|
636
788
|
}): void;
|
|
789
|
+
slotMenuItems?(slot: CompareSlot): MenuItem[];
|
|
637
790
|
renderSlotActions?(slot: CompareSlot): ReactNode;
|
|
638
791
|
}
|
|
639
792
|
interface MediaJobsProps {
|
|
@@ -661,4 +814,4 @@ interface MediaToolsClient {
|
|
|
661
814
|
resolve(input: VideoInput): Promise<ResolvedVideo>;
|
|
662
815
|
}
|
|
663
816
|
|
|
664
|
-
export { type AcceptedJob, type CompareSlot, Config, type EditDescriptor, type EditReadData, type Geometry, type JobPage, type JobState, type MediaJob, type MediaJobsProps, type MediaRequest, type MediaToolsClient, type MediaToolsConfig, type MediaToolsService, type PixelRect, type ProcessSequence, type ProcessVideo, type Recipe, type ResolvedVideo, type SaveEdit, type SavedEdit, type SequenceVideoInput, type VideoCompareProps, type VideoEditorProps, type VideoFileRef, type VideoInput, type VideoMetadata, canvas, editDescriptor, geometry, jobStates, jobsQuery, mediaError, mediaRequest, metadata, normalizeRecipe, packageVersion, processSequence, processVideo, readSavedEdit, recipe, sameFile, saveEdit, versionRef, videoFileRef, videoInput };
|
|
817
|
+
export { type AcceptedJob, type CompareSlot, Config, type EditDescriptor, type EditReadData, type ExportSettings, type Geometry, type JobPage, type JobState, type MediaJob, type MediaJobsProps, type MediaRequest, type MediaToolsClient, type MediaToolsConfig, type MediaToolsService, type PixelRect, type ProcessSequence, type ProcessVideo, type Recipe, type ResolvedVideo, type SaveEdit, type SavedEdit, type SequenceVideoInput, type VideoCompareProps, type VideoEditorProps, type VideoExportProps, type VideoFileRef, type VideoInput, type VideoMetadata, canvas, editDescriptor, exportFormat, exportSettings, geometry, jobStates, jobsQuery, mediaError, mediaRequest, metadata, normalizeRecipe, packageVersion, processSequence, processVideo, readSavedEdit, recipe, sameFile, saveEdit, versionRef, videoFileRef, videoInput };
|