@dantea/opencut 0.1.0 → 0.2.0
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/commands.d.ts +9 -1
- package/dist/commands.js +32 -5
- package/dist/index.js +1 -0
- package/dist/inspection.js +5 -0
- package/dist/mix-options.d.ts +59 -0
- package/dist/mix-options.js +23 -0
- package/dist/system-probe +0 -0
- package/dist/video.d.ts +1 -1
- package/dist/video.js +28 -3
- package/docs/AUDIO_MIX.md +132 -0
- package/docs/CLI.md +46 -6
- package/docs/INSTALL.md +13 -8
- package/docs/SDK.md +14 -3
- package/docs/VIDEO_DEFINITIONS.md +17 -8
- package/node_modules/@opencut/core/dist/index.d.ts +1 -0
- package/node_modules/@opencut/core/dist/index.js +1 -0
- package/node_modules/@opencut/core/dist/inspection.d.ts +115 -0
- package/node_modules/@opencut/core/dist/professional-mix.d.ts +129 -0
- package/node_modules/@opencut/core/dist/professional-mix.js +70 -0
- package/node_modules/@opencut/core/dist/project.d.ts +68 -0
- package/node_modules/@opencut/core/dist/project.js +15 -0
- package/node_modules/@opencut/core/dist/render-plan.d.ts +5 -1
- package/node_modules/@opencut/core/dist/render-plan.js +11 -4
- package/node_modules/@opencut/core/dist/render-sources.d.ts +4 -0
- package/node_modules/@opencut/core/dist/timeline-view.d.ts +1 -0
- package/node_modules/@opencut/core/dist/video-audio-mix.d.ts +25 -0
- package/node_modules/@opencut/core/dist/video-audio-mix.js +36 -0
- package/node_modules/@opencut/core/dist/video-build.js +2 -2
- package/node_modules/@opencut/core/dist/video-compiler.d.ts +3 -0
- package/node_modules/@opencut/core/dist/video-compiler.js +20 -1
- package/node_modules/@opencut/core/dist/video-definition.d.ts +121 -0
- package/node_modules/@opencut/core/dist/video-definition.js +6 -1
- package/node_modules/@opencut/core/dist/video-files.d.ts +55 -0
- package/node_modules/@opencut/core/dist/video-media-cache.d.ts +15 -0
- package/node_modules/@opencut/core/dist/{video-recipe-cache.js → video-media-cache.js} +7 -7
- package/node_modules/@opencut/core/dist/video-package-format.d.ts +53 -0
- package/node_modules/@opencut/core/dist/video-picture-cache.d.ts +3 -0
- package/node_modules/@opencut/core/dist/video-picture-cache.js +29 -0
- package/node_modules/@opencut/core/dist/video-preview.d.ts +56 -1
- package/node_modules/@opencut/core/dist/video-preview.js +7 -2
- package/node_modules/@opencut/core/dist/video-processing.js +2 -2
- package/node_modules/@opencut/core/dist/video-render.d.ts +14 -4
- package/node_modules/@opencut/core/dist/video-render.js +21 -3
- package/node_modules/@opencut/core/dist/video-watch.d.ts +5 -0
- package/node_modules/@opencut/core/dist/video-watch.js +18 -2
- package/node_modules/@opencut/core/dist/video.d.ts +5 -0
- package/node_modules/@opencut/core/dist/video.js +2 -0
- package/node_modules/@opencut/core/package.json +3 -3
- package/node_modules/@opencut/media/dist/audio-graph.d.ts +88 -0
- package/node_modules/@opencut/media/dist/audio-graph.js +292 -0
- package/node_modules/@opencut/media/dist/audio-mastering.d.ts +29 -0
- package/node_modules/@opencut/media/dist/audio-mastering.js +205 -0
- package/node_modules/@opencut/media/dist/deepfilter.d.ts +4 -0
- package/node_modules/@opencut/media/dist/deepfilter.js +76 -0
- package/node_modules/@opencut/media/dist/dialogue-analysis.d.ts +32 -0
- package/node_modules/@opencut/media/dist/dialogue-analysis.js +214 -0
- package/node_modules/@opencut/media/dist/enhance.js +11 -3
- package/node_modules/@opencut/media/dist/index.d.ts +4 -1
- package/node_modules/@opencut/media/dist/index.js +1 -1
- package/node_modules/@opencut/media/dist/picture-cache.d.ts +39 -0
- package/node_modules/@opencut/media/dist/picture-cache.js +169 -0
- package/node_modules/@opencut/media/dist/picture-seek.d.ts +4 -0
- package/node_modules/@opencut/media/dist/picture-seek.js +77 -0
- package/node_modules/@opencut/media/dist/process-memory +0 -0
- package/node_modules/@opencut/media/dist/process.d.ts +2 -1
- package/node_modules/@opencut/media/dist/process.js +13 -4
- package/node_modules/@opencut/media/dist/professional-mix.d.ts +34 -0
- package/node_modules/@opencut/media/dist/professional-mix.js +411 -0
- package/node_modules/@opencut/media/dist/render-budget.d.ts +1 -1
- package/node_modules/@opencut/media/dist/render-budget.js +7 -5
- package/node_modules/@opencut/media/dist/render.d.ts +33 -47
- package/node_modules/@opencut/media/dist/render.js +273 -333
- package/node_modules/@opencut/media/dist/transform-layer.d.ts +7 -1
- package/node_modules/@opencut/media/dist/transform-layer.js +32 -2
- package/node_modules/@opencut/media/dist/video-enhance +0 -0
- package/node_modules/@opencut/media/dist/video-filter.d.ts +2 -0
- package/node_modules/@opencut/media/dist/video-filter.js +4 -0
- package/node_modules/@opencut/media/dist/video-interpolate +0 -0
- package/node_modules/@opencut/media/package.json +2 -2
- package/node_modules/@opencut/sdk/dist/index.d.ts +2 -2
- package/node_modules/@opencut/sdk/dist/index.js +1 -1
- package/node_modules/@opencut/sdk/package.json +3 -3
- package/node_modules/@opencut/shared/dist/index.d.ts +1 -0
- package/node_modules/@opencut/shared/dist/index.js +1 -0
- package/node_modules/@opencut/shared/dist/professional-mix.d.ts +98 -0
- package/node_modules/@opencut/shared/dist/professional-mix.js +30 -0
- package/node_modules/@opencut/shared/package.json +1 -1
- package/package.json +5 -5
- package/skills/video-editor/SKILL.md +13 -1
- package/skills/video-editor/references/cli.md +14 -0
- package/skills/video-editor/references/sdk.md +9 -0
- package/skills/video-editor/references/video-definitions.md +7 -3
- package/node_modules/@opencut/core/dist/video-recipe-cache.d.ts +0 -16
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AudioMixCache, RenderControls } from '@opencut/media';
|
|
2
|
+
import type { CompiledVideo } from './video-compiler.js';
|
|
3
|
+
export declare function openAudioMixCache(directory: string | undefined, signal?: AbortSignal): Promise<AudioMixCache | undefined>;
|
|
4
|
+
export type AudioMixAnalysisOptions = Pick<RenderControls, 'signal' | 'audioSampleRate' | 'audioChannels' | 'audioBitrateKbps' | 'audioComparison'> & {
|
|
5
|
+
audioMixCacheDirectory?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
/** Analyze the exact PCM mix and decoded AAC without composing the picture. */
|
|
8
|
+
export declare function analyzeVideoMix(video: CompiledVideo, { audioMixCacheDirectory, ...settings }?: AudioMixAnalysisOptions): Promise<{
|
|
9
|
+
automation: {
|
|
10
|
+
dialogue: {
|
|
11
|
+
[k: string]: import("@opencut/shared").MixGainPoint[];
|
|
12
|
+
};
|
|
13
|
+
music: import("@opencut/shared").MixGainPoint[];
|
|
14
|
+
};
|
|
15
|
+
target: {
|
|
16
|
+
integratedLufs: number;
|
|
17
|
+
truePeakDbtp: number;
|
|
18
|
+
loudnessRange: number;
|
|
19
|
+
};
|
|
20
|
+
input: import("@opencut/media").LoudnessMeasurement;
|
|
21
|
+
output: import("@opencut/media").LoudnessMeasurement;
|
|
22
|
+
comparison: "after" | "before";
|
|
23
|
+
normalization: "linear" | "dynamic" | "none";
|
|
24
|
+
warnings: string[];
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mkdir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { analyzeTimelineAudioMix, MediaError } from '@opencut/media';
|
|
5
|
+
import { materializeMediaEntry } from './video-media-cache.js';
|
|
6
|
+
import { withRenderSources } from './render-sources.js';
|
|
7
|
+
export async function openAudioMixCache(directory, signal = new AbortController().signal) {
|
|
8
|
+
if (directory === undefined)
|
|
9
|
+
return;
|
|
10
|
+
if (!directory.trim())
|
|
11
|
+
throw new MediaError('Choose an audio mix cache directory.');
|
|
12
|
+
const root = resolve(directory, 'audio-mix-v1');
|
|
13
|
+
await mkdir(root, { recursive: true, mode: 0o700 });
|
|
14
|
+
const cache = await realpath(root);
|
|
15
|
+
return {
|
|
16
|
+
async materialize(key, encode) {
|
|
17
|
+
const { entry } = await materializeMediaEntry(cache, key, 'wav', signal, encode);
|
|
18
|
+
return entry.metadata.path;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Analyze the exact PCM mix and decoded AAC without composing the picture. */
|
|
23
|
+
export async function analyzeVideoMix(video, { audioMixCacheDirectory, ...settings } = {}) {
|
|
24
|
+
const { signal } = settings;
|
|
25
|
+
return withRenderSources(video, signal, async (plan) => {
|
|
26
|
+
const audioMixCache = await openAudioMixCache(audioMixCacheDirectory, signal);
|
|
27
|
+
return analyzeTimelineAudioMix({
|
|
28
|
+
...plan,
|
|
29
|
+
...settings,
|
|
30
|
+
...(audioMixCache && { audioMixCache }),
|
|
31
|
+
output: join(tmpdir(), 'mix.mp4'),
|
|
32
|
+
scratchDirectory: tmpdir(),
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=video-audio-mix.js.map
|
|
@@ -5,7 +5,7 @@ import { parseVideoDefinition, VideoDefinitionError, } from './video-definition.
|
|
|
5
5
|
import { fileLease, fingerprintFile, hashJson, missing, syncPath, writeCheckpoint, } from './video-integrity.js';
|
|
6
6
|
import { videoInputIdentity } from './video-input.js';
|
|
7
7
|
import { processingSettings } from './video-processing.js';
|
|
8
|
-
import {
|
|
8
|
+
import { findMediaEntry } from './video-media-cache.js';
|
|
9
9
|
import { inheritsRenderQuality, recipeFormatSchema, } from './video-recipe-schema.js';
|
|
10
10
|
const sha256 = z.string().regex(/^[a-f0-9]{64}$/);
|
|
11
11
|
const fingerprint = z.object({ sha256, bytes: z.int().nonnegative() });
|
|
@@ -311,7 +311,7 @@ export async function inspectBuildCheckpoint(build, signal) {
|
|
|
311
311
|
: compile.state;
|
|
312
312
|
const steps = [];
|
|
313
313
|
for (const step of compile.steps) {
|
|
314
|
-
const result = await
|
|
314
|
+
const result = await findMediaEntry(cache, step.key, step.format, signal);
|
|
315
315
|
const entry = result?.entry;
|
|
316
316
|
steps.push({
|
|
317
317
|
...step,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VideoMixEdit } from '@opencut/shared';
|
|
1
2
|
import type { MediaMetadata, RenderQuality } from '@opencut/media';
|
|
2
3
|
import type { VideoAssetOptions } from './video-assets.js';
|
|
3
4
|
import type { Project } from './project.js';
|
|
@@ -8,6 +9,7 @@ import type { VideoRecipeInspection } from './video-recipe.js';
|
|
|
8
9
|
type BoundRenderPlan = ReturnType<typeof bindRenderSources>;
|
|
9
10
|
export type CompilationOptions = VideoAssetOptions & {
|
|
10
11
|
preview?: boolean;
|
|
12
|
+
audioMixEdit?: VideoMixEdit | undefined;
|
|
11
13
|
};
|
|
12
14
|
export interface CompiledVideo {
|
|
13
15
|
readonly path: string;
|
|
@@ -16,6 +18,7 @@ export interface CompiledVideo {
|
|
|
16
18
|
readonly project: Project;
|
|
17
19
|
readonly frameCount: number;
|
|
18
20
|
readonly recipes: readonly VideoRecipeInspection[];
|
|
21
|
+
readonly audioMixEdit?: VideoMixEdit;
|
|
19
22
|
forQuality(quality: RenderQuality, preview: boolean, signal?: AbortSignal): Promise<CompiledVideo>;
|
|
20
23
|
/** Media identity recorded before probing, keyed by the bound source path. */
|
|
21
24
|
sourceIdentity(path: string): string | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { videoMixEditSchema } from './professional-mix.js';
|
|
1
2
|
import { createHash } from 'node:crypto';
|
|
2
3
|
import { dirname, resolve } from 'node:path';
|
|
3
4
|
import { audioSourceDuration, videoSourceDuration, validateEmbeddedFont, validateSubtitleBurnIn, renderQualities, } from '@opencut/media';
|
|
@@ -35,6 +36,9 @@ export async function compileDefinition(path, value, options = {}, getBuild) {
|
|
|
35
36
|
if (!renderQualities.includes(quality))
|
|
36
37
|
throw new VideoDefinitionError('Choose fast, quality, or maximum render quality.');
|
|
37
38
|
const definition = freeze(parseVideoDefinition(value));
|
|
39
|
+
const audioMixEdit = options.audioMixEdit === undefined
|
|
40
|
+
? undefined
|
|
41
|
+
: freeze(videoMixEditSchema.parse(options.audioMixEdit));
|
|
38
42
|
const recipeSteps = [];
|
|
39
43
|
const { processing, probes = new Map() } = options;
|
|
40
44
|
const authoredFiles = [
|
|
@@ -54,6 +58,7 @@ export async function compileDefinition(path, value, options = {}, getBuild) {
|
|
|
54
58
|
const { project, assets, recipes, qualitySensitive } = await buildProject(path, definition, {
|
|
55
59
|
...options,
|
|
56
60
|
quality,
|
|
61
|
+
audioMixEdit,
|
|
57
62
|
probes,
|
|
58
63
|
...(getBuild && {
|
|
59
64
|
processing: {
|
|
@@ -103,6 +108,7 @@ export async function compileDefinition(path, value, options = {}, getBuild) {
|
|
|
103
108
|
path,
|
|
104
109
|
...(build && { build: freeze(build) }),
|
|
105
110
|
project: freeze(project),
|
|
111
|
+
...(audioMixEdit && { audioMixEdit }),
|
|
106
112
|
frameCount: renderPlan.frameCount,
|
|
107
113
|
recipes: freeze(recipes),
|
|
108
114
|
async forQuality(next, preview, signal) {
|
|
@@ -120,6 +126,7 @@ export async function compileDefinition(path, value, options = {}, getBuild) {
|
|
|
120
126
|
processing,
|
|
121
127
|
probes,
|
|
122
128
|
pinnedSources,
|
|
129
|
+
audioMixEdit,
|
|
123
130
|
...(recovery && { recovery }),
|
|
124
131
|
}, getBuild);
|
|
125
132
|
checkInputs(next);
|
|
@@ -137,8 +144,11 @@ export async function compileDefinition(path, value, options = {}, getBuild) {
|
|
|
137
144
|
return compiled;
|
|
138
145
|
}
|
|
139
146
|
async function buildProject(path, definition, options) {
|
|
140
|
-
const { signal, inputs } = options;
|
|
147
|
+
const { signal, inputs, audioMixEdit } = options;
|
|
141
148
|
const { canvas, assets = {}, tracks, name = 'Untitled video', id = stableId('video', name), createdAt = epoch, updatedAt = createdAt, transitions, markers, } = definition;
|
|
149
|
+
const professionalMix = audioMixEdit
|
|
150
|
+
? audioMixEdit.mix
|
|
151
|
+
: definition.professionalMix;
|
|
142
152
|
const { frameRate: authoredRate, ...settings } = canvas;
|
|
143
153
|
const frameRate = typeof authoredRate === 'number'
|
|
144
154
|
? { numerator: authoredRate, denominator: 1 }
|
|
@@ -151,6 +161,7 @@ async function buildProject(path, definition, options) {
|
|
|
151
161
|
clips: [],
|
|
152
162
|
transitions,
|
|
153
163
|
markers,
|
|
164
|
+
...(professionalMix && { professionalMix }),
|
|
154
165
|
};
|
|
155
166
|
const resolveFont = await loadFonts(path, definition.fonts, signal, inputs?.record, options.pinnedSources);
|
|
156
167
|
const { subtitles } = definition;
|
|
@@ -173,8 +184,13 @@ async function buildProject(path, definition, options) {
|
|
|
173
184
|
for (const [trackIndex, track] of tracks.entries()) {
|
|
174
185
|
const { id, name, type, clips, ...properties } = track;
|
|
175
186
|
const trackId = id ?? generatedTrackId(track, occurrences);
|
|
187
|
+
const roles = audioMixEdit?.roles;
|
|
188
|
+
const role = roles && Object.hasOwn(roles, trackId) ? roles[trackId] : undefined;
|
|
189
|
+
if (role && type !== 'audio' && type !== 'video')
|
|
190
|
+
throw new VideoDefinitionError(`Track '${trackId}' does not support audio routing.`);
|
|
176
191
|
project.tracks.push({
|
|
177
192
|
...properties,
|
|
193
|
+
...(role && { audioRole: role }),
|
|
178
194
|
id: trackId,
|
|
179
195
|
name: name ?? type,
|
|
180
196
|
type: type === 'audio' ? 'audio' : 'video',
|
|
@@ -194,6 +210,9 @@ async function buildProject(path, definition, options) {
|
|
|
194
210
|
project.clips.push(await compileClip(clip, frameRate, trackId, location, resolveFont, 'text' in clip || asset?.kind === 'image'));
|
|
195
211
|
}
|
|
196
212
|
}
|
|
213
|
+
for (const id of Object.keys(audioMixEdit?.roles ?? {}))
|
|
214
|
+
if (!project.tracks.some((track) => track.id === id))
|
|
215
|
+
throw new VideoDefinitionError(`Unknown audio track '${id}'.`);
|
|
197
216
|
const clipAssets = new Set(project.clips.flatMap(({ assetId }) => (assetId ? [assetId] : [])));
|
|
198
217
|
const compiled = await compileVideoAssets(dirname(path), assets, clipAssets, options);
|
|
199
218
|
project.assets = [...compiled.assets.values()].map(({ asset }) => asset);
|
|
@@ -121,6 +121,11 @@ export declare const videoDefinitionSchema: z.ZodObject<{
|
|
|
121
121
|
tracks: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
122
122
|
volume: z.ZodOptional<z.ZodNumber>;
|
|
123
123
|
muted: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
audioRole: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
dialogue: "dialogue";
|
|
126
|
+
music: "music";
|
|
127
|
+
other: "other";
|
|
128
|
+
}>>;
|
|
124
129
|
id: z.ZodOptional<z.ZodString>;
|
|
125
130
|
name: z.ZodOptional<z.ZodString>;
|
|
126
131
|
type: z.ZodLiteral<"video">;
|
|
@@ -495,6 +500,11 @@ export declare const videoDefinitionSchema: z.ZodObject<{
|
|
|
495
500
|
}, z.core.$strict>, z.ZodObject<{
|
|
496
501
|
volume: z.ZodOptional<z.ZodNumber>;
|
|
497
502
|
muted: z.ZodOptional<z.ZodBoolean>;
|
|
503
|
+
audioRole: z.ZodOptional<z.ZodEnum<{
|
|
504
|
+
dialogue: "dialogue";
|
|
505
|
+
music: "music";
|
|
506
|
+
other: "other";
|
|
507
|
+
}>>;
|
|
498
508
|
id: z.ZodOptional<z.ZodString>;
|
|
499
509
|
name: z.ZodOptional<z.ZodString>;
|
|
500
510
|
type: z.ZodLiteral<"audio">;
|
|
@@ -1139,6 +1149,64 @@ export declare const videoDefinitionSchema: z.ZodObject<{
|
|
|
1139
1149
|
frame: z.ZodInt;
|
|
1140
1150
|
name: z.ZodString;
|
|
1141
1151
|
}, z.core.$strict>>>;
|
|
1152
|
+
professionalMix: z.ZodOptional<z.ZodObject<{
|
|
1153
|
+
preset: z.ZodEnum<{
|
|
1154
|
+
"natural-cinematic": "natural-cinematic";
|
|
1155
|
+
"clear-voiceover": "clear-voiceover";
|
|
1156
|
+
}>;
|
|
1157
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1158
|
+
cleanup: z.ZodOptional<z.ZodNumber>;
|
|
1159
|
+
warmth: z.ZodOptional<z.ZodNumber>;
|
|
1160
|
+
clarity: z.ZodOptional<z.ZodNumber>;
|
|
1161
|
+
consistency: z.ZodOptional<z.ZodNumber>;
|
|
1162
|
+
dialogueLufs: z.ZodOptional<z.ZodNumber>;
|
|
1163
|
+
highPassHz: z.ZodOptional<z.ZodNumber>;
|
|
1164
|
+
eq: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1165
|
+
frequency: z.ZodNumber;
|
|
1166
|
+
q: z.ZodNumber;
|
|
1167
|
+
db: z.ZodNumber;
|
|
1168
|
+
}, z.core.$strict>>>;
|
|
1169
|
+
deEsser: z.ZodOptional<z.ZodNumber>;
|
|
1170
|
+
compressor: z.ZodOptional<z.ZodObject<{
|
|
1171
|
+
thresholdDb: z.ZodNumber;
|
|
1172
|
+
ratio: z.ZodNumber;
|
|
1173
|
+
attackMs: z.ZodNumber;
|
|
1174
|
+
releaseMs: z.ZodNumber;
|
|
1175
|
+
}, z.core.$strict>>;
|
|
1176
|
+
ai: z.ZodOptional<z.ZodLiteral<"deepfilternet">>;
|
|
1177
|
+
dereverb: z.ZodOptional<z.ZodNumber>;
|
|
1178
|
+
matching: z.ZodOptional<z.ZodObject<{
|
|
1179
|
+
amount: z.ZodNumber;
|
|
1180
|
+
referenceClip: z.ZodOptional<z.ZodString>;
|
|
1181
|
+
}, z.core.$strict>>;
|
|
1182
|
+
crossfadeMs: z.ZodOptional<z.ZodNumber>;
|
|
1183
|
+
ducking: z.ZodOptional<z.ZodObject<{
|
|
1184
|
+
depthDb: z.ZodOptional<z.ZodNumber>;
|
|
1185
|
+
attackMs: z.ZodOptional<z.ZodNumber>;
|
|
1186
|
+
holdMs: z.ZodOptional<z.ZodNumber>;
|
|
1187
|
+
releaseMs: z.ZodOptional<z.ZodNumber>;
|
|
1188
|
+
}, z.core.$strict>>;
|
|
1189
|
+
delivery: z.ZodOptional<z.ZodObject<{
|
|
1190
|
+
preset: z.ZodEnum<{
|
|
1191
|
+
web: "web";
|
|
1192
|
+
broadcast: "broadcast";
|
|
1193
|
+
film: "film";
|
|
1194
|
+
}>;
|
|
1195
|
+
integratedLufs: z.ZodOptional<z.ZodNumber>;
|
|
1196
|
+
truePeakDbtp: z.ZodOptional<z.ZodNumber>;
|
|
1197
|
+
loudnessRange: z.ZodOptional<z.ZodNumber>;
|
|
1198
|
+
}, z.core.$strict>>;
|
|
1199
|
+
automation: z.ZodOptional<z.ZodObject<{
|
|
1200
|
+
dialogue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1201
|
+
sample: z.ZodInt;
|
|
1202
|
+
db: z.ZodNumber;
|
|
1203
|
+
}, z.core.$strict>>>>;
|
|
1204
|
+
music: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1205
|
+
sample: z.ZodInt;
|
|
1206
|
+
db: z.ZodNumber;
|
|
1207
|
+
}, z.core.$strict>>>;
|
|
1208
|
+
}, z.core.$strict>>;
|
|
1209
|
+
}, z.core.$strict>>;
|
|
1142
1210
|
id: z.ZodOptional<z.ZodString>;
|
|
1143
1211
|
name: z.ZodOptional<z.ZodString>;
|
|
1144
1212
|
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
@@ -1492,6 +1560,7 @@ export declare function parseVideoDefinition(value: unknown): {
|
|
|
1492
1560
|
})[];
|
|
1493
1561
|
volume?: number | undefined;
|
|
1494
1562
|
muted?: boolean | undefined;
|
|
1563
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
1495
1564
|
id?: string | undefined;
|
|
1496
1565
|
name?: string | undefined;
|
|
1497
1566
|
} | {
|
|
@@ -1638,6 +1707,7 @@ export declare function parseVideoDefinition(value: unknown): {
|
|
|
1638
1707
|
}[];
|
|
1639
1708
|
volume?: number | undefined;
|
|
1640
1709
|
muted?: boolean | undefined;
|
|
1710
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
1641
1711
|
id?: string | undefined;
|
|
1642
1712
|
name?: string | undefined;
|
|
1643
1713
|
} | {
|
|
@@ -2121,6 +2191,57 @@ export declare function parseVideoDefinition(value: unknown): {
|
|
|
2121
2191
|
frame: number;
|
|
2122
2192
|
name: string;
|
|
2123
2193
|
}[] | undefined;
|
|
2194
|
+
professionalMix?: {
|
|
2195
|
+
preset: "natural-cinematic" | "clear-voiceover";
|
|
2196
|
+
enabled?: boolean | undefined;
|
|
2197
|
+
cleanup?: number | undefined;
|
|
2198
|
+
warmth?: number | undefined;
|
|
2199
|
+
clarity?: number | undefined;
|
|
2200
|
+
consistency?: number | undefined;
|
|
2201
|
+
dialogueLufs?: number | undefined;
|
|
2202
|
+
highPassHz?: number | undefined;
|
|
2203
|
+
eq?: {
|
|
2204
|
+
frequency: number;
|
|
2205
|
+
q: number;
|
|
2206
|
+
db: number;
|
|
2207
|
+
}[] | undefined;
|
|
2208
|
+
deEsser?: number | undefined;
|
|
2209
|
+
compressor?: {
|
|
2210
|
+
thresholdDb: number;
|
|
2211
|
+
ratio: number;
|
|
2212
|
+
attackMs: number;
|
|
2213
|
+
releaseMs: number;
|
|
2214
|
+
} | undefined;
|
|
2215
|
+
ai?: "deepfilternet" | undefined;
|
|
2216
|
+
dereverb?: number | undefined;
|
|
2217
|
+
matching?: {
|
|
2218
|
+
amount: number;
|
|
2219
|
+
referenceClip?: string | undefined;
|
|
2220
|
+
} | undefined;
|
|
2221
|
+
crossfadeMs?: number | undefined;
|
|
2222
|
+
ducking?: {
|
|
2223
|
+
depthDb?: number | undefined;
|
|
2224
|
+
attackMs?: number | undefined;
|
|
2225
|
+
holdMs?: number | undefined;
|
|
2226
|
+
releaseMs?: number | undefined;
|
|
2227
|
+
} | undefined;
|
|
2228
|
+
delivery?: {
|
|
2229
|
+
preset: "web" | "broadcast" | "film";
|
|
2230
|
+
integratedLufs?: number | undefined;
|
|
2231
|
+
truePeakDbtp?: number | undefined;
|
|
2232
|
+
loudnessRange?: number | undefined;
|
|
2233
|
+
} | undefined;
|
|
2234
|
+
automation?: {
|
|
2235
|
+
dialogue?: Record<string, {
|
|
2236
|
+
sample: number;
|
|
2237
|
+
db: number;
|
|
2238
|
+
}[]> | undefined;
|
|
2239
|
+
music?: {
|
|
2240
|
+
sample: number;
|
|
2241
|
+
db: number;
|
|
2242
|
+
}[] | undefined;
|
|
2243
|
+
} | undefined;
|
|
2244
|
+
} | undefined;
|
|
2124
2245
|
id?: string | undefined;
|
|
2125
2246
|
name?: string | undefined;
|
|
2126
2247
|
createdAt?: string | undefined;
|
|
@@ -56,7 +56,11 @@ const track = trackSchema.omit({ id: true, name: true, type: true }).extend({
|
|
|
56
56
|
id: entityIdSchema.optional(),
|
|
57
57
|
name: trackSchema.shape.name.optional(),
|
|
58
58
|
});
|
|
59
|
-
const visualOnlyTrack = track.omit({
|
|
59
|
+
const visualOnlyTrack = track.omit({
|
|
60
|
+
volume: true,
|
|
61
|
+
muted: true,
|
|
62
|
+
audioRole: true,
|
|
63
|
+
});
|
|
60
64
|
const asset = assetSchema
|
|
61
65
|
.pick({ name: true, freezeFrame: true, provenance: true })
|
|
62
66
|
.partial()
|
|
@@ -100,6 +104,7 @@ export const videoDefinitionSchema = z.strictObject({
|
|
|
100
104
|
subtitles: subtitles.optional(),
|
|
101
105
|
transitions: z.array(transitionSchema).optional(),
|
|
102
106
|
markers: z.array(markerSchema).optional(),
|
|
107
|
+
professionalMix: snapshotSchema.shape.professionalMix,
|
|
103
108
|
});
|
|
104
109
|
const parametersSchema = z.record(z.string(), z.json());
|
|
105
110
|
const parameterized = Symbol('videoParameters');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VideoMixEdit } from '@opencut/shared';
|
|
1
2
|
import type { VideoParameters } from './video-definition.js';
|
|
2
3
|
import type { CompilationOptions, CompiledVideo } from './video-compiler.js';
|
|
3
4
|
import { processingSettings } from './video-processing.js';
|
|
@@ -7,6 +8,7 @@ export declare function isVideoDefinitionPath(file: string): boolean;
|
|
|
7
8
|
export type VideoCompileOptions = Pick<CompilationOptions, 'signal' | 'preview' | 'processing' | 'quality'> & {
|
|
8
9
|
/** A JSON object validated by the TypeScript definition. */
|
|
9
10
|
params?: unknown;
|
|
11
|
+
audioMixEdit?: VideoMixEdit | undefined;
|
|
10
12
|
};
|
|
11
13
|
type InputOptions = CompilationOptions & VideoCompileOptions & {
|
|
12
14
|
checkpoint?: boolean;
|
|
@@ -406,6 +408,7 @@ export declare function readVideoInput(file: string, options: InputOptions, reco
|
|
|
406
408
|
})[];
|
|
407
409
|
volume?: number | undefined;
|
|
408
410
|
muted?: boolean | undefined;
|
|
411
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
409
412
|
id?: string | undefined;
|
|
410
413
|
name?: string | undefined;
|
|
411
414
|
} | {
|
|
@@ -552,6 +555,7 @@ export declare function readVideoInput(file: string, options: InputOptions, reco
|
|
|
552
555
|
}[];
|
|
553
556
|
volume?: number | undefined;
|
|
554
557
|
muted?: boolean | undefined;
|
|
558
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
555
559
|
id?: string | undefined;
|
|
556
560
|
name?: string | undefined;
|
|
557
561
|
} | {
|
|
@@ -1035,6 +1039,57 @@ export declare function readVideoInput(file: string, options: InputOptions, reco
|
|
|
1035
1039
|
frame: number;
|
|
1036
1040
|
name: string;
|
|
1037
1041
|
}[] | undefined;
|
|
1042
|
+
professionalMix?: {
|
|
1043
|
+
preset: "natural-cinematic" | "clear-voiceover";
|
|
1044
|
+
enabled?: boolean | undefined;
|
|
1045
|
+
cleanup?: number | undefined;
|
|
1046
|
+
warmth?: number | undefined;
|
|
1047
|
+
clarity?: number | undefined;
|
|
1048
|
+
consistency?: number | undefined;
|
|
1049
|
+
dialogueLufs?: number | undefined;
|
|
1050
|
+
highPassHz?: number | undefined;
|
|
1051
|
+
eq?: {
|
|
1052
|
+
frequency: number;
|
|
1053
|
+
q: number;
|
|
1054
|
+
db: number;
|
|
1055
|
+
}[] | undefined;
|
|
1056
|
+
deEsser?: number | undefined;
|
|
1057
|
+
compressor?: {
|
|
1058
|
+
thresholdDb: number;
|
|
1059
|
+
ratio: number;
|
|
1060
|
+
attackMs: number;
|
|
1061
|
+
releaseMs: number;
|
|
1062
|
+
} | undefined;
|
|
1063
|
+
ai?: "deepfilternet" | undefined;
|
|
1064
|
+
dereverb?: number | undefined;
|
|
1065
|
+
matching?: {
|
|
1066
|
+
amount: number;
|
|
1067
|
+
referenceClip?: string | undefined;
|
|
1068
|
+
} | undefined;
|
|
1069
|
+
crossfadeMs?: number | undefined;
|
|
1070
|
+
ducking?: {
|
|
1071
|
+
depthDb?: number | undefined;
|
|
1072
|
+
attackMs?: number | undefined;
|
|
1073
|
+
holdMs?: number | undefined;
|
|
1074
|
+
releaseMs?: number | undefined;
|
|
1075
|
+
} | undefined;
|
|
1076
|
+
delivery?: {
|
|
1077
|
+
preset: "web" | "broadcast" | "film";
|
|
1078
|
+
integratedLufs?: number | undefined;
|
|
1079
|
+
truePeakDbtp?: number | undefined;
|
|
1080
|
+
loudnessRange?: number | undefined;
|
|
1081
|
+
} | undefined;
|
|
1082
|
+
automation?: {
|
|
1083
|
+
dialogue?: Record<string, {
|
|
1084
|
+
sample: number;
|
|
1085
|
+
db: number;
|
|
1086
|
+
}[]> | undefined;
|
|
1087
|
+
music?: {
|
|
1088
|
+
sample: number;
|
|
1089
|
+
db: number;
|
|
1090
|
+
}[] | undefined;
|
|
1091
|
+
} | undefined;
|
|
1092
|
+
} | undefined;
|
|
1038
1093
|
id?: string | undefined;
|
|
1039
1094
|
name?: string | undefined;
|
|
1040
1095
|
createdAt?: string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MediaMetadata } from '@opencut/media';
|
|
2
|
+
import type { IdentifiedMedia } from './video-input.js';
|
|
3
|
+
type MediaEntry = IdentifiedMedia & {
|
|
4
|
+
sha256: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function materializeMediaEntry(directory: string, key: string, format: string, signal: AbortSignal, encode: (output: string) => Promise<MediaMetadata>): Promise<{
|
|
7
|
+
entry: MediaEntry;
|
|
8
|
+
reused: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
/** Find validated media without publishing or removing anything. */
|
|
11
|
+
export declare function findMediaEntry(directory: string, key: string, format: string, signal?: AbortSignal): Promise<{
|
|
12
|
+
directory: string;
|
|
13
|
+
entry: MediaEntry;
|
|
14
|
+
} | undefined>;
|
|
15
|
+
export {};
|
|
@@ -15,7 +15,7 @@ const receipt = z.strictObject({
|
|
|
15
15
|
Array.isArray(value.streams) &&
|
|
16
16
|
!('path' in value)),
|
|
17
17
|
});
|
|
18
|
-
export async function
|
|
18
|
+
export async function materializeMediaEntry(directory, key, format, signal, encode) {
|
|
19
19
|
const release = await fileLease(join(directory, `.lock-${key.slice(0, 2)}.sqlite`), signal);
|
|
20
20
|
const staging = stageDirectory(directory, key);
|
|
21
21
|
try {
|
|
@@ -34,7 +34,7 @@ export async function materializeRecipeEntry(directory, key, format, signal, enc
|
|
|
34
34
|
reused,
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
const cached = await
|
|
37
|
+
const cached = await findMediaEntry(directory, key, format, signal);
|
|
38
38
|
if (cached?.directory === target)
|
|
39
39
|
return { entry: cached.entry, reused: true };
|
|
40
40
|
await rm(target, { recursive: true, force: true });
|
|
@@ -70,10 +70,10 @@ export async function materializeRecipeEntry(directory, key, format, signal, enc
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
/** Find validated media without publishing or removing anything. */
|
|
73
|
-
export async function
|
|
73
|
+
export async function findMediaEntry(directory, key, format, signal) {
|
|
74
74
|
const target = join(directory, key);
|
|
75
75
|
const published = async () => {
|
|
76
|
-
const entry = await
|
|
76
|
+
const entry = await readMediaEntry(target, key, format, signal);
|
|
77
77
|
return entry && { directory: target, entry };
|
|
78
78
|
};
|
|
79
79
|
const cached = await published();
|
|
@@ -92,7 +92,7 @@ export async function findRecipeEntry(directory, key, format, signal) {
|
|
|
92
92
|
if (!/^attempt-[a-zA-Z0-9]{6}$/.test(name))
|
|
93
93
|
continue;
|
|
94
94
|
const attempt = join(staging, name);
|
|
95
|
-
const entry = await
|
|
95
|
+
const entry = await readMediaEntry(attempt, key, format, signal).catch(async (error) => {
|
|
96
96
|
// An inspector can race a writer moving the attempt to its final location.
|
|
97
97
|
if (signal?.aborted || (await statIfPresent(attempt)))
|
|
98
98
|
throw error;
|
|
@@ -108,7 +108,7 @@ async function statIfPresent(path) {
|
|
|
108
108
|
throw error;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
async function
|
|
111
|
+
async function readMediaEntry(target, key, format, signal) {
|
|
112
112
|
const path = join(target, `media.${format}`);
|
|
113
113
|
const manifest = join(target, 'result.json');
|
|
114
114
|
try {
|
|
@@ -134,4 +134,4 @@ async function readRecipeEntry(target, key, format, signal) {
|
|
|
134
134
|
throw error;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
//# sourceMappingURL=video-
|
|
137
|
+
//# sourceMappingURL=video-media-cache.js.map
|
|
@@ -460,6 +460,7 @@ export declare function verifyPackageContents(directory: string, signal?: AbortS
|
|
|
460
460
|
})[];
|
|
461
461
|
volume?: number | undefined;
|
|
462
462
|
muted?: boolean | undefined;
|
|
463
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
463
464
|
id?: string | undefined;
|
|
464
465
|
name?: string | undefined;
|
|
465
466
|
} | {
|
|
@@ -606,6 +607,7 @@ export declare function verifyPackageContents(directory: string, signal?: AbortS
|
|
|
606
607
|
}[];
|
|
607
608
|
volume?: number | undefined;
|
|
608
609
|
muted?: boolean | undefined;
|
|
610
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
609
611
|
id?: string | undefined;
|
|
610
612
|
name?: string | undefined;
|
|
611
613
|
} | {
|
|
@@ -1089,6 +1091,57 @@ export declare function verifyPackageContents(directory: string, signal?: AbortS
|
|
|
1089
1091
|
frame: number;
|
|
1090
1092
|
name: string;
|
|
1091
1093
|
}[] | undefined;
|
|
1094
|
+
professionalMix?: {
|
|
1095
|
+
preset: "natural-cinematic" | "clear-voiceover";
|
|
1096
|
+
enabled?: boolean | undefined;
|
|
1097
|
+
cleanup?: number | undefined;
|
|
1098
|
+
warmth?: number | undefined;
|
|
1099
|
+
clarity?: number | undefined;
|
|
1100
|
+
consistency?: number | undefined;
|
|
1101
|
+
dialogueLufs?: number | undefined;
|
|
1102
|
+
highPassHz?: number | undefined;
|
|
1103
|
+
eq?: {
|
|
1104
|
+
frequency: number;
|
|
1105
|
+
q: number;
|
|
1106
|
+
db: number;
|
|
1107
|
+
}[] | undefined;
|
|
1108
|
+
deEsser?: number | undefined;
|
|
1109
|
+
compressor?: {
|
|
1110
|
+
thresholdDb: number;
|
|
1111
|
+
ratio: number;
|
|
1112
|
+
attackMs: number;
|
|
1113
|
+
releaseMs: number;
|
|
1114
|
+
} | undefined;
|
|
1115
|
+
ai?: "deepfilternet" | undefined;
|
|
1116
|
+
dereverb?: number | undefined;
|
|
1117
|
+
matching?: {
|
|
1118
|
+
amount: number;
|
|
1119
|
+
referenceClip?: string | undefined;
|
|
1120
|
+
} | undefined;
|
|
1121
|
+
crossfadeMs?: number | undefined;
|
|
1122
|
+
ducking?: {
|
|
1123
|
+
depthDb?: number | undefined;
|
|
1124
|
+
attackMs?: number | undefined;
|
|
1125
|
+
holdMs?: number | undefined;
|
|
1126
|
+
releaseMs?: number | undefined;
|
|
1127
|
+
} | undefined;
|
|
1128
|
+
delivery?: {
|
|
1129
|
+
preset: "web" | "broadcast" | "film";
|
|
1130
|
+
integratedLufs?: number | undefined;
|
|
1131
|
+
truePeakDbtp?: number | undefined;
|
|
1132
|
+
loudnessRange?: number | undefined;
|
|
1133
|
+
} | undefined;
|
|
1134
|
+
automation?: {
|
|
1135
|
+
dialogue?: Record<string, {
|
|
1136
|
+
sample: number;
|
|
1137
|
+
db: number;
|
|
1138
|
+
}[]> | undefined;
|
|
1139
|
+
music?: {
|
|
1140
|
+
sample: number;
|
|
1141
|
+
db: number;
|
|
1142
|
+
}[] | undefined;
|
|
1143
|
+
} | undefined;
|
|
1144
|
+
} | undefined;
|
|
1092
1145
|
id?: string | undefined;
|
|
1093
1146
|
name?: string | undefined;
|
|
1094
1147
|
createdAt?: string | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mkdir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { MediaError, recipeBackendVersion } from '@opencut/media';
|
|
4
|
+
import { videoInputIdentity } from './video-input.js';
|
|
5
|
+
import { materializeMediaEntry } from './video-media-cache.js';
|
|
6
|
+
export async function openPictureCache(directory, video, signal = new AbortController().signal) {
|
|
7
|
+
if (!directory.trim())
|
|
8
|
+
throw new MediaError('Choose a picture cache directory.');
|
|
9
|
+
const root = resolve(directory, 'picture-v1');
|
|
10
|
+
await mkdir(root, { recursive: true, mode: 0o700 });
|
|
11
|
+
const cache = await realpath(root);
|
|
12
|
+
if (/[\r\n]/.test(cache))
|
|
13
|
+
throw new MediaError('Picture cache paths cannot contain line breaks.');
|
|
14
|
+
return {
|
|
15
|
+
backend: await recipeBackendVersion(signal),
|
|
16
|
+
sourceIdentity(path) {
|
|
17
|
+
signal.throwIfAborted();
|
|
18
|
+
const identity = video.sourceIdentity(path);
|
|
19
|
+
if (!identity || videoInputIdentity(path) !== identity)
|
|
20
|
+
throw new MediaError(`Media '${path}' changed after it was read. Compile the definition again.`);
|
|
21
|
+
return identity;
|
|
22
|
+
},
|
|
23
|
+
async materialize(key, encode) {
|
|
24
|
+
const { entry, reused } = await materializeMediaEntry(cache, key, 'nut', signal, encode);
|
|
25
|
+
return { path: entry.metadata.path, reused };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=video-picture-cache.js.map
|