@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
|
@@ -76,6 +76,7 @@ export declare function previewVideo(video: CompiledVideo): {
|
|
|
76
76
|
id: string;
|
|
77
77
|
name: string;
|
|
78
78
|
type: "video" | "audio";
|
|
79
|
+
audioRole?: "dialogue" | "music" | "other" | undefined;
|
|
79
80
|
volume?: number | undefined;
|
|
80
81
|
muted?: boolean | undefined;
|
|
81
82
|
}[];
|
|
@@ -338,6 +339,57 @@ export declare function previewVideo(video: CompiledVideo): {
|
|
|
338
339
|
frame: number;
|
|
339
340
|
name: string;
|
|
340
341
|
}[] | undefined;
|
|
342
|
+
professionalMix?: {
|
|
343
|
+
preset: "natural-cinematic" | "clear-voiceover";
|
|
344
|
+
enabled?: boolean | undefined;
|
|
345
|
+
cleanup?: number | undefined;
|
|
346
|
+
warmth?: number | undefined;
|
|
347
|
+
clarity?: number | undefined;
|
|
348
|
+
consistency?: number | undefined;
|
|
349
|
+
dialogueLufs?: number | undefined;
|
|
350
|
+
highPassHz?: number | undefined;
|
|
351
|
+
eq?: {
|
|
352
|
+
frequency: number;
|
|
353
|
+
q: number;
|
|
354
|
+
db: number;
|
|
355
|
+
}[] | undefined;
|
|
356
|
+
deEsser?: number | undefined;
|
|
357
|
+
compressor?: {
|
|
358
|
+
thresholdDb: number;
|
|
359
|
+
ratio: number;
|
|
360
|
+
attackMs: number;
|
|
361
|
+
releaseMs: number;
|
|
362
|
+
} | undefined;
|
|
363
|
+
ai?: "deepfilternet" | undefined;
|
|
364
|
+
dereverb?: number | undefined;
|
|
365
|
+
matching?: {
|
|
366
|
+
amount: number;
|
|
367
|
+
referenceClip?: string | undefined;
|
|
368
|
+
} | undefined;
|
|
369
|
+
crossfadeMs?: number | undefined;
|
|
370
|
+
ducking?: {
|
|
371
|
+
depthDb?: number | undefined;
|
|
372
|
+
attackMs?: number | undefined;
|
|
373
|
+
holdMs?: number | undefined;
|
|
374
|
+
releaseMs?: number | undefined;
|
|
375
|
+
} | undefined;
|
|
376
|
+
delivery?: {
|
|
377
|
+
preset: "web" | "broadcast" | "film";
|
|
378
|
+
integratedLufs?: number | undefined;
|
|
379
|
+
truePeakDbtp?: number | undefined;
|
|
380
|
+
loudnessRange?: number | undefined;
|
|
381
|
+
} | undefined;
|
|
382
|
+
automation?: {
|
|
383
|
+
dialogue?: Record<string, {
|
|
384
|
+
sample: number;
|
|
385
|
+
db: number;
|
|
386
|
+
}[]> | undefined;
|
|
387
|
+
music?: {
|
|
388
|
+
sample: number;
|
|
389
|
+
db: number;
|
|
390
|
+
}[] | undefined;
|
|
391
|
+
} | undefined;
|
|
392
|
+
} | undefined;
|
|
341
393
|
};
|
|
342
394
|
inspectFrame: (position: PreviewPosition) => {
|
|
343
395
|
inspectionVersion: 1;
|
|
@@ -1198,7 +1250,10 @@ export declare function previewVideo(video: CompiledVideo): {
|
|
|
1198
1250
|
y: number;
|
|
1199
1251
|
}[];
|
|
1200
1252
|
}>;
|
|
1201
|
-
clip(selection: Required<VideoPreviewRange>, output: string, options?: VideoPreviewOptions & Pick<RenderControls, "onProgress">
|
|
1253
|
+
clip(selection: Required<VideoPreviewRange>, output: string, options?: VideoPreviewOptions & Pick<RenderControls, "onProgress" | "audioComparison"> & {
|
|
1254
|
+
audioMixCacheDirectory?: string | undefined;
|
|
1255
|
+
}): Promise<{
|
|
1256
|
+
audioMix?: import("@opencut/media").AudioMixReport;
|
|
1202
1257
|
inspectionVersion: 1;
|
|
1203
1258
|
path: string;
|
|
1204
1259
|
projectPath: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { renderContactSheet, renderTimelineFrame, renderVideoTimeline, } from '@opencut/media';
|
|
2
2
|
import { inspectProject, inspectTimeline, previewClipSchema, previewFrameSchema, previewSheetSchema, } from './inspection.js';
|
|
3
3
|
import { frameTime, timeSchema } from './time.js';
|
|
4
|
+
import { openAudioMixCache } from './video-audio-mix.js';
|
|
4
5
|
import { withRenderSources } from './render-sources.js';
|
|
5
6
|
export class VideoPreviewRangeError extends RangeError {
|
|
6
7
|
}
|
|
@@ -95,16 +96,19 @@ export function previewVideo(video) {
|
|
|
95
96
|
const { signal, onProgress } = options;
|
|
96
97
|
const quality = options.quality ?? 'fast';
|
|
97
98
|
const revision = await video.forQuality(quality, true, signal);
|
|
98
|
-
const
|
|
99
|
+
const audioMixCache = await openAudioMixCache(options.audioMixCacheDirectory, signal);
|
|
100
|
+
const { path, width, height, frameCount, durationSeconds, audioMix } = await withRenderSources(revision, signal, (plan) => renderVideoTimeline({
|
|
99
101
|
...plan,
|
|
100
102
|
signal,
|
|
101
103
|
...(onProgress && { onProgress }),
|
|
102
104
|
maxDimension: options.maxDimension ?? 640,
|
|
105
|
+
audioComparison: options.audioComparison,
|
|
106
|
+
...(audioMixCache && { audioMixCache }),
|
|
103
107
|
quality,
|
|
104
108
|
output,
|
|
105
109
|
range: { startFrame, endFrame },
|
|
106
110
|
}));
|
|
107
|
-
|
|
111
|
+
const result = previewClipSchema.parse({
|
|
108
112
|
...base,
|
|
109
113
|
path,
|
|
110
114
|
width,
|
|
@@ -118,6 +122,7 @@ export function previewVideo(video) {
|
|
|
118
122
|
startTime: frameTime(startFrame, frameRate),
|
|
119
123
|
endTime: frameTime(endFrame, frameRate),
|
|
120
124
|
});
|
|
125
|
+
return { ...result, ...(audioMix && { audioMix }) };
|
|
121
126
|
},
|
|
122
127
|
};
|
|
123
128
|
}
|
|
@@ -6,7 +6,7 @@ import { MediaError, enhancementBackendVersion, hostRenderResources, interpolati
|
|
|
6
6
|
import { fingerprintFile, hashJson } from './video-integrity.js';
|
|
7
7
|
import { videoInputIdentity } from './video-input.js';
|
|
8
8
|
import { isEnhancementStep, isInterpolationStep, } from './video-recipe-schema.js';
|
|
9
|
-
import {
|
|
9
|
+
import { materializeMediaEntry } from './video-media-cache.js';
|
|
10
10
|
import { recipeArguments, recipeMedia, recipeStepError, resolveRecipeStep, validateRecipeOutput, } from './video-recipe.js';
|
|
11
11
|
const MiB = 1024 * 1024;
|
|
12
12
|
function recipeAdmission(budget, signal) {
|
|
@@ -126,7 +126,7 @@ async function processRecipe({ input, inspection: { assetId, steps } }, director
|
|
|
126
126
|
key,
|
|
127
127
|
format: step.format,
|
|
128
128
|
});
|
|
129
|
-
const { entry, reused } = await
|
|
129
|
+
const { entry, reused } = await materializeMediaEntry(directory, key, step.format, signal, async (output) => {
|
|
130
130
|
assertCurrent(current);
|
|
131
131
|
if (step.media.kind !== 'audio' &&
|
|
132
132
|
[inputMedia, step.media].some((media) => pixels(media) > limits.maxPixels))
|
|
@@ -2,19 +2,25 @@ import type { RenderControls } from '@opencut/media';
|
|
|
2
2
|
import type { CompiledVideo } from './video-compiler.js';
|
|
3
3
|
import type { VideoProcessingOptions } from './video-processing.js';
|
|
4
4
|
import type { VideoBuild, VideoCompileOptions } from './video-files.js';
|
|
5
|
+
import type { VideoMixEdit } from '@opencut/shared';
|
|
5
6
|
export type VideoRenderOptions = Omit<RenderControls, 'range' | 'maxDimension'> & {
|
|
6
7
|
burnSubtitles?: boolean;
|
|
8
|
+
pictureCacheDirectory?: string | undefined;
|
|
9
|
+
audioMixCacheDirectory?: string | undefined;
|
|
10
|
+
audioMixEdit?: VideoCompileOptions['audioMixEdit'];
|
|
7
11
|
processing?: VideoProcessingOptions | undefined;
|
|
8
12
|
params?: VideoCompileOptions['params'];
|
|
9
13
|
};
|
|
10
|
-
export type CompiledVideoRenderOptions = Omit<VideoRenderOptions, 'processing' | 'params'>;
|
|
11
|
-
export type VideoRenderConfiguration = Omit<RenderControls, 'onProgress' | 'signal' | 'overwrite'> & Pick<CompiledVideoRenderOptions, 'burnSubtitles'
|
|
14
|
+
export type CompiledVideoRenderOptions = Omit<VideoRenderOptions, 'processing' | 'params' | 'audioMixEdit'>;
|
|
15
|
+
export type VideoRenderConfiguration = Omit<RenderControls, 'onProgress' | 'signal' | 'overwrite'> & Pick<CompiledVideoRenderOptions, 'burnSubtitles'> & {
|
|
16
|
+
audioMixEdit?: VideoMixEdit;
|
|
17
|
+
};
|
|
12
18
|
export interface VideoRenderBuild extends VideoBuild {
|
|
13
19
|
readonly version: 1;
|
|
14
20
|
readonly render: Readonly<VideoRenderConfiguration>;
|
|
15
21
|
}
|
|
16
22
|
/** Render one compiled revision using the shared media engine. */
|
|
17
|
-
export declare function renderCompiledVideo(video: CompiledVideo, output: string, { burnSubtitles, quality, ...options }?: CompiledVideoRenderOptions): Promise<{
|
|
23
|
+
export declare function renderCompiledVideo(video: CompiledVideo, output: string, { burnSubtitles, quality, pictureCacheDirectory, audioMixCacheDirectory, ...options }?: CompiledVideoRenderOptions): Promise<{
|
|
18
24
|
build?: VideoRenderBuild;
|
|
19
25
|
codec: import("@opencut/media").RenderCodec;
|
|
20
26
|
quality: import("@opencut/media").RenderQuality;
|
|
@@ -30,9 +36,11 @@ export declare function renderCompiledVideo(video: CompiledVideo, output: string
|
|
|
30
36
|
durationSeconds: number;
|
|
31
37
|
metadata: import("@opencut/media").MediaMetadata;
|
|
32
38
|
warnings?: string[];
|
|
39
|
+
pictureRanges?: import("@opencut/media").PictureRange[];
|
|
40
|
+
audioMix?: import("@opencut/media").AudioMixReport;
|
|
33
41
|
}>;
|
|
34
42
|
/** Compile and render in the calling process. Subprocesses are scoped to this call. */
|
|
35
|
-
export declare function renderVideo(file: string, output: string, { params, processing, ...options }?: VideoRenderOptions): Promise<{
|
|
43
|
+
export declare function renderVideo(file: string, output: string, { params, processing, audioMixEdit, ...options }?: VideoRenderOptions): Promise<{
|
|
36
44
|
build?: VideoRenderBuild;
|
|
37
45
|
codec: import("@opencut/media").RenderCodec;
|
|
38
46
|
quality: import("@opencut/media").RenderQuality;
|
|
@@ -48,4 +56,6 @@ export declare function renderVideo(file: string, output: string, { params, proc
|
|
|
48
56
|
durationSeconds: number;
|
|
49
57
|
metadata: import("@opencut/media").MediaMetadata;
|
|
50
58
|
warnings?: string[];
|
|
59
|
+
pictureRanges?: import("@opencut/media").PictureRange[];
|
|
60
|
+
audioMix?: import("@opencut/media").AudioMixReport;
|
|
51
61
|
}>;
|
|
@@ -5,6 +5,8 @@ import { authoredInputs, checkpointRender } from './video-build.js';
|
|
|
5
5
|
import { withRenderSources } from './render-sources.js';
|
|
6
6
|
import { compileVideo } from './video-files.js';
|
|
7
7
|
import { isInterpolationStep } from './video-recipe-schema.js';
|
|
8
|
+
import { openAudioMixCache } from './video-audio-mix.js';
|
|
9
|
+
import { openPictureCache } from './video-picture-cache.js';
|
|
8
10
|
async function statIfPresent(path) {
|
|
9
11
|
try {
|
|
10
12
|
return await stat(path);
|
|
@@ -33,7 +35,7 @@ async function protectInputs(video, output, boundSources, signal) {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
/** Render one compiled revision using the shared media engine. */
|
|
36
|
-
export async function renderCompiledVideo(video, output, { burnSubtitles = true, quality = 'quality', ...options } = {}) {
|
|
38
|
+
export async function renderCompiledVideo(video, output, { burnSubtitles = true, quality = 'quality', pictureCacheDirectory, audioMixCacheDirectory, ...options } = {}) {
|
|
37
39
|
const { onProgress, signal, overwrite, ...settings } = options;
|
|
38
40
|
video = await video.forQuality(quality, !burnSubtitles, signal);
|
|
39
41
|
// Record the controls the shared renderer receives, including runtime callers.
|
|
@@ -60,21 +62,36 @@ export async function renderCompiledVideo(video, output, { burnSubtitles = true,
|
|
|
60
62
|
audioSampleRate: settings.audioSampleRate ?? 48000,
|
|
61
63
|
audioChannels: settings.audioChannels ?? 2,
|
|
62
64
|
burnSubtitles,
|
|
65
|
+
...(settings.audioComparison && {
|
|
66
|
+
audioComparison: settings.audioComparison,
|
|
67
|
+
}),
|
|
68
|
+
...(video.audioMixEdit && { audioMixEdit: video.audioMixEdit }),
|
|
63
69
|
},
|
|
64
70
|
};
|
|
65
71
|
const buildMetadata = build && JSON.stringify(build);
|
|
66
72
|
signal?.throwIfAborted();
|
|
67
|
-
return checkpointRender(video, output, {
|
|
73
|
+
return checkpointRender(video, output, {
|
|
74
|
+
...settings,
|
|
75
|
+
quality,
|
|
76
|
+
burnSubtitles,
|
|
77
|
+
...(video.audioMixEdit && { audioMixEdit: video.audioMixEdit }),
|
|
78
|
+
}, signal, (scratchDirectory, onVerifiedOutput) => withRenderSources(video, signal, async (plan) => {
|
|
68
79
|
if (overwrite)
|
|
69
80
|
await protectInputs(video, output, plan.sourceMetadata.keys(), signal);
|
|
70
81
|
if (!burnSubtitles)
|
|
71
82
|
plan.visualClips = plan.visualClips.filter((clip) => !clip.subtitle);
|
|
83
|
+
const pictureCache = pictureCacheDirectory === undefined
|
|
84
|
+
? undefined
|
|
85
|
+
: await openPictureCache(pictureCacheDirectory, video, signal);
|
|
86
|
+
const audioMixCache = await openAudioMixCache(audioMixCacheDirectory, signal);
|
|
72
87
|
const result = await renderVideoTimeline({
|
|
73
88
|
...plan,
|
|
74
89
|
...settings,
|
|
75
90
|
quality,
|
|
76
91
|
signal,
|
|
77
92
|
overwrite,
|
|
93
|
+
pictureCache,
|
|
94
|
+
...(audioMixCache && { audioMixCache }),
|
|
78
95
|
...(onProgress && { onProgress }),
|
|
79
96
|
...(buildMetadata && { buildMetadata }),
|
|
80
97
|
...(scratchDirectory && { scratchDirectory }),
|
|
@@ -89,13 +106,14 @@ export async function renderCompiledVideo(video, output, { burnSubtitles = true,
|
|
|
89
106
|
}, scratchDirectory));
|
|
90
107
|
}
|
|
91
108
|
/** Compile and render in the calling process. Subprocesses are scoped to this call. */
|
|
92
|
-
export async function renderVideo(file, output, { params, processing, ...options } = {}) {
|
|
109
|
+
export async function renderVideo(file, output, { params, processing, audioMixEdit, ...options } = {}) {
|
|
93
110
|
const video = await compileVideo(file, {
|
|
94
111
|
signal: options.signal,
|
|
95
112
|
preview: options.burnSubtitles === false,
|
|
96
113
|
processing,
|
|
97
114
|
quality: options.quality ?? 'quality',
|
|
98
115
|
params,
|
|
116
|
+
audioMixEdit,
|
|
99
117
|
});
|
|
100
118
|
return renderCompiledVideo(video, output, options);
|
|
101
119
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VideoMixEdit } from '@opencut/shared';
|
|
1
2
|
import type { RenderQuality, VideoTimelineResult } from '@opencut/media';
|
|
2
3
|
import type { CompiledVideo } from './video-compiler.js';
|
|
3
4
|
import type { VideoProcessingOptions } from './video-processing.js';
|
|
@@ -22,10 +23,14 @@ export interface VideoWatchOptions {
|
|
|
22
23
|
quality?: RenderQuality | undefined;
|
|
23
24
|
processing?: VideoProcessingOptions;
|
|
24
25
|
signal?: AbortSignal;
|
|
26
|
+
audioMixEdit?: VideoMixEdit | undefined;
|
|
27
|
+
audioComparison?: 'before' | 'after' | undefined;
|
|
28
|
+
audioMixCacheDirectory?: string | undefined;
|
|
25
29
|
}
|
|
26
30
|
/** Watch only inputs of the selected definition, retaining one playable revision. */
|
|
27
31
|
export declare function watchVideo(file: string, options: VideoWatchOptions): Promise<{
|
|
28
32
|
path: string;
|
|
29
33
|
close: () => Promise<void>;
|
|
30
34
|
withCurrent: <T>(generation: number, run: (video: CompiledVideo) => Promise<T>) => Promise<T>;
|
|
35
|
+
setAudioMix: (edit: VideoMixEdit | undefined, comparison?: "after" | "before") => void;
|
|
31
36
|
}>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { openAudioMixCache } from './video-audio-mix.js';
|
|
1
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
3
|
import { mkdtemp, readFile, realpath, rm } from 'node:fs/promises';
|
|
3
4
|
import { tmpdir } from 'node:os';
|
|
@@ -20,6 +21,8 @@ export async function watchVideo(file, options) {
|
|
|
20
21
|
maxDimension: options.maxDimension ?? 640,
|
|
21
22
|
quality: options.quality ?? 'fast',
|
|
22
23
|
};
|
|
24
|
+
let audioMixEdit = options.audioMixEdit;
|
|
25
|
+
let audioComparison = options.audioComparison;
|
|
23
26
|
const renders = new Map();
|
|
24
27
|
let published;
|
|
25
28
|
let active;
|
|
@@ -98,6 +101,7 @@ export async function watchVideo(file, options) {
|
|
|
98
101
|
const inputs = new Map();
|
|
99
102
|
const media = new Set();
|
|
100
103
|
const output = join(directory, `revision-${next}.mp4`);
|
|
104
|
+
const comparison = audioComparison;
|
|
101
105
|
const record = (input) => {
|
|
102
106
|
if (!inputs.has(input.path))
|
|
103
107
|
inputs.set(input.path, input);
|
|
@@ -111,6 +115,7 @@ export async function watchVideo(file, options) {
|
|
|
111
115
|
signal,
|
|
112
116
|
probes,
|
|
113
117
|
processing: options.processing,
|
|
118
|
+
audioMixEdit,
|
|
114
119
|
scriptWorker: {},
|
|
115
120
|
inputs: {
|
|
116
121
|
record,
|
|
@@ -154,17 +159,23 @@ export async function watchVideo(file, options) {
|
|
|
154
159
|
// The bound paths identify immutable media copies. Edits that leave
|
|
155
160
|
// the composition unchanged can publish a new revision with the same MP4.
|
|
156
161
|
const renderKey = createHash('sha256')
|
|
157
|
-
.update(JSON.stringify([plan, settings]))
|
|
162
|
+
.update(JSON.stringify([plan, settings, comparison]))
|
|
158
163
|
.digest('hex');
|
|
159
164
|
let playback = published?.renderKey === renderKey
|
|
160
165
|
? published.revision.playback
|
|
161
166
|
: undefined;
|
|
162
167
|
if (!playback) {
|
|
163
168
|
emit('rendering', next);
|
|
169
|
+
const audioMixCache = video.project.professionalMix?.ai &&
|
|
170
|
+
video.project.professionalMix.enabled !== false
|
|
171
|
+
? await openAudioMixCache(options.audioMixCacheDirectory ?? directory, signal)
|
|
172
|
+
: undefined;
|
|
164
173
|
playback = await withDefaultRenderBudget(signal, () => renderVideoTimeline({
|
|
165
174
|
...plan,
|
|
166
175
|
sourceMetadata,
|
|
167
176
|
...settings,
|
|
177
|
+
audioComparison: comparison,
|
|
178
|
+
...(audioMixCache && { audioMixCache }),
|
|
168
179
|
output,
|
|
169
180
|
signal,
|
|
170
181
|
}));
|
|
@@ -256,6 +267,11 @@ export async function watchVideo(file, options) {
|
|
|
256
267
|
await pruneSnapshots();
|
|
257
268
|
}
|
|
258
269
|
}
|
|
259
|
-
|
|
270
|
+
function setAudioMix(edit, comparison = 'after') {
|
|
271
|
+
audioMixEdit = edit;
|
|
272
|
+
audioComparison = comparison;
|
|
273
|
+
schedule();
|
|
274
|
+
}
|
|
275
|
+
return { path, close, withCurrent, setAudioMix };
|
|
260
276
|
}
|
|
261
277
|
//# sourceMappingURL=video-watch.js.map
|
|
@@ -24,3 +24,8 @@ export type { VideoBatchOptions, VideoBatchProgress, VideoBatchResult, VideoVari
|
|
|
24
24
|
export { packageVideo, verifyVideoPackage } from './video-package.js';
|
|
25
25
|
export type { VideoPackageOptions } from './video-package.js';
|
|
26
26
|
export type { VideoPackageManifest } from './video-package-format.js';
|
|
27
|
+
export { analyzeVideoMix } from './video-audio-mix.js';
|
|
28
|
+
export type { AudioMixAnalysisOptions } from './video-audio-mix.js';
|
|
29
|
+
export { audioRoleSchema, professionalMixSchema, videoMixEditSchema, } from './professional-mix.js';
|
|
30
|
+
export type { AudioRole, DeliveryPreset, DialoguePreset, MixAutomation, MixGainPoint, ProfessionalMix, VideoMixEdit, } from '@opencut/shared';
|
|
31
|
+
export type { AudioMixReport } from '@opencut/media';
|
|
@@ -11,4 +11,6 @@ export { renderVideo, renderCompiledVideo } from './video-render.js';
|
|
|
11
11
|
export { watchVideo } from './video-watch.js';
|
|
12
12
|
export { batchRenderVideo } from './video-batch.js';
|
|
13
13
|
export { packageVideo, verifyVideoPackage } from './video-package.js';
|
|
14
|
+
export { analyzeVideoMix } from './video-audio-mix.js';
|
|
15
|
+
export { audioRoleSchema, professionalMixSchema, videoMixEditSchema, } from './professional-mix.js';
|
|
14
16
|
//# sourceMappingURL=video.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencut/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@opencut/media": "0.
|
|
17
|
-
"@opencut/shared": "0.
|
|
16
|
+
"@opencut/media": "0.2.0",
|
|
17
|
+
"@opencut/shared": "0.2.0",
|
|
18
18
|
"typescript": "6.0.3",
|
|
19
19
|
"zod": "4.6.7"
|
|
20
20
|
},
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { AudioRole, MixGainPoint, RenderTimeMapping } from '@opencut/shared';
|
|
2
|
+
import type { MediaMetadata } from './probe.js';
|
|
3
|
+
import type { VideoTimelineOptions } from './render.js';
|
|
4
|
+
type Rational = RenderTimeMapping['sourceIn'];
|
|
5
|
+
interface RenderAudioFade {
|
|
6
|
+
duration: Rational;
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AudioRenderClip {
|
|
11
|
+
trackId?: string;
|
|
12
|
+
role?: AudioRole;
|
|
13
|
+
clipId: string;
|
|
14
|
+
path: string;
|
|
15
|
+
timelineStartFrame: number;
|
|
16
|
+
sourceStartFrame: number;
|
|
17
|
+
frameCount: number;
|
|
18
|
+
retiming?: RenderTimeMapping;
|
|
19
|
+
tempoRunId?: string;
|
|
20
|
+
volume: number;
|
|
21
|
+
muted: boolean;
|
|
22
|
+
fadeIn?: RenderAudioFade;
|
|
23
|
+
fadeOut?: RenderAudioFade;
|
|
24
|
+
gainKeys?: {
|
|
25
|
+
time: Rational;
|
|
26
|
+
value: number;
|
|
27
|
+
}[];
|
|
28
|
+
effects?: Array<{
|
|
29
|
+
type: 'eq';
|
|
30
|
+
frequency: number;
|
|
31
|
+
db: number;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'compressor';
|
|
34
|
+
threshold: number;
|
|
35
|
+
ratio: number;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'limiter';
|
|
38
|
+
ceiling: number;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'de-esser';
|
|
41
|
+
amount: number;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'reverb';
|
|
44
|
+
mix: number;
|
|
45
|
+
}>;
|
|
46
|
+
required: boolean;
|
|
47
|
+
padAudio?: true;
|
|
48
|
+
}
|
|
49
|
+
export declare function audioSampleAtFrame(frame: number, rate: VideoTimelineOptions['frameRate'], offset?: Rational, sign?: bigint): number;
|
|
50
|
+
export declare function audioClipSample(frameRate: VideoTimelineOptions['frameRate'], clip: AudioRenderClip, edge: 'start' | 'end', fade?: Rational): number;
|
|
51
|
+
export interface StagedDialogue {
|
|
52
|
+
path: string;
|
|
53
|
+
pre: number;
|
|
54
|
+
fadeIn: {
|
|
55
|
+
offset: number;
|
|
56
|
+
length: number;
|
|
57
|
+
} | undefined;
|
|
58
|
+
fadeOut: {
|
|
59
|
+
offset: number;
|
|
60
|
+
length: number;
|
|
61
|
+
} | undefined;
|
|
62
|
+
toneDb: number;
|
|
63
|
+
gain: MixGainPoint[];
|
|
64
|
+
}
|
|
65
|
+
export declare function audioSourceSamples(clip: AudioRenderClip, frameRate: VideoTimelineOptions['frameRate']): {
|
|
66
|
+
start: number;
|
|
67
|
+
end: number;
|
|
68
|
+
};
|
|
69
|
+
export declare function groupAudioRuns(clips: AudioRenderClip[], accepts: (previous: AudioRenderClip, clip: AudioRenderClip) => boolean): AudioRenderClip[][];
|
|
70
|
+
export declare function buildAudioGraph(options: Pick<VideoTimelineOptions, 'frameRate' | 'audioClips'>, { filters, readSource, inputPathFor, openInput, }: {
|
|
71
|
+
filters: string[];
|
|
72
|
+
readSource: (clip: AudioRenderClip) => Promise<MediaMetadata>;
|
|
73
|
+
inputPathFor: (path: string) => string | Promise<string>;
|
|
74
|
+
openInput: (clip: AudioRenderClip, path: string) => number;
|
|
75
|
+
}, { total: totalSamples, from, to, }: {
|
|
76
|
+
total: number;
|
|
77
|
+
from: number;
|
|
78
|
+
to: number;
|
|
79
|
+
}, mode?: {
|
|
80
|
+
isolate: {
|
|
81
|
+
pre: number;
|
|
82
|
+
post: number;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
dialogue?: ReadonlyMap<string, StagedDialogue>;
|
|
86
|
+
music?: MixGainPoint[];
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
export {};
|