@dantea/opencut 0.1.3 → 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 +8 -1
- package/dist/commands.js +30 -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 +21 -3
- package/docs/AUDIO_MIX.md +132 -0
- package/docs/CLI.md +6 -0
- package/docs/INSTALL.md +1 -1
- package/docs/SDK.md +4 -0
- package/docs/VIDEO_DEFINITIONS.md +4 -0
- 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 +4 -1
- package/node_modules/@opencut/core/dist/render-plan.js +6 -0
- package/node_modules/@opencut/core/dist/render-sources.d.ts +3 -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-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-package-format.d.ts +53 -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-render.d.ts +11 -4
- package/node_modules/@opencut/core/dist/video-render.js +16 -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/index.d.ts +3 -1
- package/node_modules/@opencut/media/dist/index.js +1 -1
- 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 +28 -46
- package/node_modules/@opencut/media/dist/render.js +78 -224
- package/node_modules/@opencut/media/dist/video-enhance +0 -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 +6 -0
- package/skills/video-editor/references/cli.md +7 -0
- package/skills/video-editor/references/sdk.md +4 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { constants } from 'node:fs';
|
|
2
|
+
import { access, mkdir, realpath } from 'node:fs/promises';
|
|
3
|
+
import { delimiter, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
+
import { renderAudioFile } from './audio-mastering.js';
|
|
5
|
+
import { checkRenderSignal, localFile, MediaError, runMediaTool, sourceFileStamp, } from './process.js';
|
|
6
|
+
import { accountRenderFile } from './render-budget.js';
|
|
7
|
+
const timeout = 600_000;
|
|
8
|
+
export async function localEnhancer(signal) {
|
|
9
|
+
const configured = process.env.OPENCUT_DEEPFILTER;
|
|
10
|
+
if (configured && !isAbsolute(configured))
|
|
11
|
+
throw new MediaError('OPENCUT_DEEPFILTER must be an absolute executable path.');
|
|
12
|
+
const candidates = configured
|
|
13
|
+
? [configured]
|
|
14
|
+
: (process.env.PATH ?? '')
|
|
15
|
+
.split(delimiter)
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.map((part) => resolve(part, 'deep-filter'));
|
|
18
|
+
let executable;
|
|
19
|
+
for (const candidate of candidates) {
|
|
20
|
+
checkRenderSignal(signal);
|
|
21
|
+
const found = await access(candidate, constants.X_OK)
|
|
22
|
+
.then(() => realpath(candidate))
|
|
23
|
+
.catch(() => undefined);
|
|
24
|
+
if (found) {
|
|
25
|
+
executable = found;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!executable)
|
|
30
|
+
throw new MediaError('DeepFilterNet needs a local deep-filter executable on PATH or in OPENCUT_DEEPFILTER.');
|
|
31
|
+
const backend = executable;
|
|
32
|
+
const model = process.env.OPENCUT_DEEPFILTER_MODEL;
|
|
33
|
+
const localModel = model ? await localFile(model) : undefined;
|
|
34
|
+
const run = (args, timeout, writesFile = false) => runMediaTool(backend, args, 1024 * 1024, timeout, {
|
|
35
|
+
signal,
|
|
36
|
+
writesFile,
|
|
37
|
+
onDiagnostics() { },
|
|
38
|
+
});
|
|
39
|
+
let version;
|
|
40
|
+
try {
|
|
41
|
+
version = (await run(['--version'], 5000)).toString().trim();
|
|
42
|
+
}
|
|
43
|
+
catch (cause) {
|
|
44
|
+
checkRenderSignal(signal);
|
|
45
|
+
throw new MediaError('DeepFilterNet needs a local deep-filter executable on PATH or in OPENCUT_DEEPFILTER.', { cause });
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
key: [
|
|
49
|
+
version,
|
|
50
|
+
await sourceFileStamp(backend),
|
|
51
|
+
localModel && (await sourceFileStamp(localModel)),
|
|
52
|
+
],
|
|
53
|
+
async enhance(input, folder, outputFolder) {
|
|
54
|
+
await mkdir(outputFolder);
|
|
55
|
+
const padded = join(folder, 'speech.wav');
|
|
56
|
+
await renderAudioFile(['-i', input, '-af', 'apad=pad_len=4800', '-c:a', 'pcm_s16le'], padded, signal);
|
|
57
|
+
try {
|
|
58
|
+
await run([
|
|
59
|
+
'-D',
|
|
60
|
+
'-o',
|
|
61
|
+
outputFolder,
|
|
62
|
+
...(localModel ? ['-m', localModel] : []),
|
|
63
|
+
padded,
|
|
64
|
+
], timeout, true);
|
|
65
|
+
}
|
|
66
|
+
catch (cause) {
|
|
67
|
+
checkRenderSignal(signal);
|
|
68
|
+
throw new MediaError(`DeepFilterNet could not process the local dialogue. ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
69
|
+
}
|
|
70
|
+
const output = join(outputFolder, 'speech.wav');
|
|
71
|
+
await accountRenderFile(output);
|
|
72
|
+
return output;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=deepfilter.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MixGainPoint } from '@opencut/shared';
|
|
2
|
+
interface Window {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number;
|
|
5
|
+
level: number;
|
|
6
|
+
tone: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DialogueProfile {
|
|
9
|
+
windows: Window[];
|
|
10
|
+
floor: number;
|
|
11
|
+
}
|
|
12
|
+
interface Interval {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
}
|
|
16
|
+
export interface DialogueActivity {
|
|
17
|
+
phrases: Interval[];
|
|
18
|
+
level: number;
|
|
19
|
+
tone: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const clamp: (value: number, lo: number, hi: number) => number;
|
|
22
|
+
/** K-weighted stereo energy and a coarse spectral tilt estimate in 100 ms windows. */
|
|
23
|
+
export declare function profileDialogue(path: string, key: string, signal?: AbortSignal): Promise<DialogueProfile>;
|
|
24
|
+
export declare function detectDialogue(profile: DialogueProfile, pre: number, length: number, gainAt: (sample: number) => number): DialogueActivity;
|
|
25
|
+
export declare function dialogueCurve(profile: DialogueProfile, activity: DialogueActivity, target: number, intensity: number, pre: number, length: number, gainAt: (sample: number) => number): MixGainPoint[];
|
|
26
|
+
export declare function musicCurve(activity: Interval[], { depthDb, attackMs, holdMs, releaseMs, }: {
|
|
27
|
+
depthDb: number;
|
|
28
|
+
attackMs: number;
|
|
29
|
+
holdMs: number;
|
|
30
|
+
releaseMs: number;
|
|
31
|
+
}, length: number): MixGainPoint[];
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { runMediaTool } from './process.js';
|
|
2
|
+
const windowSize = 4800;
|
|
3
|
+
const rate = 12000;
|
|
4
|
+
const analysisCache = new Map();
|
|
5
|
+
export const clamp = (value, lo, hi) => Math.min(hi, Math.max(lo, value));
|
|
6
|
+
function percentile(values, q, fallback) {
|
|
7
|
+
if (!values.length)
|
|
8
|
+
return fallback;
|
|
9
|
+
return values.sort((a, b) => a - b)[Math.floor((values.length - 1) * q)];
|
|
10
|
+
}
|
|
11
|
+
/** K-weighted stereo energy and a coarse spectral tilt estimate in 100 ms windows. */
|
|
12
|
+
export async function profileDialogue(path, key, signal) {
|
|
13
|
+
const cached = analysisCache.get(key);
|
|
14
|
+
if (cached) {
|
|
15
|
+
analysisCache.delete(key);
|
|
16
|
+
analysisCache.set(key, cached);
|
|
17
|
+
return cached;
|
|
18
|
+
}
|
|
19
|
+
const windows = [];
|
|
20
|
+
let pending = Buffer.alloc(0);
|
|
21
|
+
let count = 0;
|
|
22
|
+
let energy = 0;
|
|
23
|
+
let bass = 0;
|
|
24
|
+
let high = 0;
|
|
25
|
+
let leftLow = 0;
|
|
26
|
+
let rightLow = 0;
|
|
27
|
+
let offset = 0;
|
|
28
|
+
const coefficient = 1 - Math.exp((-2 * Math.PI * 800) / rate);
|
|
29
|
+
function flush() {
|
|
30
|
+
if (!count)
|
|
31
|
+
return;
|
|
32
|
+
const end = offset + count * (48000 / rate);
|
|
33
|
+
windows.push({
|
|
34
|
+
from: offset,
|
|
35
|
+
to: end,
|
|
36
|
+
level: 10 * Math.log10(Math.max(1e-12, energy / count)) - 0.691,
|
|
37
|
+
tone: 10 * Math.log10((high + 1e-9) / (bass + 1e-9)),
|
|
38
|
+
});
|
|
39
|
+
offset = end;
|
|
40
|
+
count = energy = bass = high = 0;
|
|
41
|
+
}
|
|
42
|
+
await runMediaTool('ffmpeg', [
|
|
43
|
+
'-v',
|
|
44
|
+
'error',
|
|
45
|
+
'-nostdin',
|
|
46
|
+
'-xerror',
|
|
47
|
+
'-filter_threads',
|
|
48
|
+
'1',
|
|
49
|
+
'-i',
|
|
50
|
+
path,
|
|
51
|
+
'-map',
|
|
52
|
+
'0:a:0',
|
|
53
|
+
'-af',
|
|
54
|
+
'biquad=b0=1.53512485958697:b1=-2.69169618940638:b2=1.19839281085285:a1=-1.69065929318241:a2=0.73248077421585:precision=f64,biquad=b0=1:b1=-2:b2=1:a1=-1.99004745483398:a2=0.99007225036621:precision=f64',
|
|
55
|
+
'-ar',
|
|
56
|
+
String(rate),
|
|
57
|
+
'-ac',
|
|
58
|
+
'2',
|
|
59
|
+
'-c:a',
|
|
60
|
+
'pcm_f32le',
|
|
61
|
+
'-f',
|
|
62
|
+
'f32le',
|
|
63
|
+
'pipe:1',
|
|
64
|
+
], 64 * 1024 * 1024, 120_000, {
|
|
65
|
+
signal,
|
|
66
|
+
onStdout(chunk) {
|
|
67
|
+
if (pending.length)
|
|
68
|
+
chunk = Buffer.concat([pending, chunk]);
|
|
69
|
+
const end = chunk.length - (chunk.length % 8);
|
|
70
|
+
for (let i = 0; i < end; i += 8) {
|
|
71
|
+
const left = chunk.readFloatLE(i);
|
|
72
|
+
const right = chunk.readFloatLE(i + 4);
|
|
73
|
+
leftLow += coefficient * (left - leftLow);
|
|
74
|
+
rightLow += coefficient * (right - rightLow);
|
|
75
|
+
energy += left ** 2 + right ** 2;
|
|
76
|
+
bass += leftLow ** 2 + rightLow ** 2;
|
|
77
|
+
high += (left - leftLow) ** 2 + (right - rightLow) ** 2;
|
|
78
|
+
if (++count === windowSize / (48000 / rate))
|
|
79
|
+
flush();
|
|
80
|
+
}
|
|
81
|
+
pending = chunk.subarray(end);
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
flush();
|
|
85
|
+
const profile = {
|
|
86
|
+
windows,
|
|
87
|
+
floor: percentile(windows.map((window) => window.level), 0.15, -90),
|
|
88
|
+
};
|
|
89
|
+
analysisCache.set(key, profile);
|
|
90
|
+
if (analysisCache.size > 96)
|
|
91
|
+
analysisCache.delete(analysisCache.keys().next().value);
|
|
92
|
+
return profile;
|
|
93
|
+
}
|
|
94
|
+
export function detectDialogue(profile, pre, length, gainAt) {
|
|
95
|
+
const windows = profile.windows
|
|
96
|
+
.filter((window) => window.to > pre && window.from < pre + length)
|
|
97
|
+
.map((window) => {
|
|
98
|
+
const from = Math.max(0, window.from - pre);
|
|
99
|
+
const to = Math.min(length, window.to - pre);
|
|
100
|
+
const gain = gainAt((from + to) / 2);
|
|
101
|
+
return {
|
|
102
|
+
from,
|
|
103
|
+
to,
|
|
104
|
+
tone: window.tone,
|
|
105
|
+
level: window.level + 20 * Math.log10(gain),
|
|
106
|
+
audible: gain > 0.015,
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
const levels = windows
|
|
110
|
+
.filter(({ audible }) => audible)
|
|
111
|
+
.map(({ level }) => level);
|
|
112
|
+
const upper = percentile(levels.slice(), 0.85, -90);
|
|
113
|
+
const floor = percentile(levels, 0.15, -90);
|
|
114
|
+
const stationary = windows.length >= 12 && upper - floor < 2.5 && upper < -27;
|
|
115
|
+
// A brief utterance may sit entirely above the percentile used for typical speech.
|
|
116
|
+
const threshold = Math.max(-64, upper - 27, stationary ? floor + 7 : Math.min(floor + 7, upper - 3));
|
|
117
|
+
const active = windows.filter(({ audible, level }) => audible && level >= threshold);
|
|
118
|
+
const phrases = [];
|
|
119
|
+
const voiced = [];
|
|
120
|
+
let start = 0;
|
|
121
|
+
while (start < active.length) {
|
|
122
|
+
let end = start + 1;
|
|
123
|
+
while (end < active.length &&
|
|
124
|
+
active[end].from - active[end - 1].to <= 9600)
|
|
125
|
+
end++;
|
|
126
|
+
const { from, level } = active[start];
|
|
127
|
+
const { to } = active[end - 1];
|
|
128
|
+
// Remove isolated low-level impacts while retaining strong one-window utterances.
|
|
129
|
+
if (to - from >= 7200 || level >= Math.max(-42, upper - 5)) {
|
|
130
|
+
phrases.push({ from, to });
|
|
131
|
+
voiced.push(...active.slice(start, end));
|
|
132
|
+
}
|
|
133
|
+
start = end;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
phrases,
|
|
137
|
+
level: percentile(voiced.map(({ level }) => level), 0.65, -Infinity),
|
|
138
|
+
tone: percentile(voiced.map(({ tone }) => tone), 0.5, 0),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function point(keys, sample, db) {
|
|
142
|
+
const value = db === 0 ? 0 : db;
|
|
143
|
+
const last = keys.at(-1);
|
|
144
|
+
if (last?.sample === sample)
|
|
145
|
+
last.db = value;
|
|
146
|
+
else
|
|
147
|
+
keys.push({ sample, db: value });
|
|
148
|
+
}
|
|
149
|
+
export function dialogueCurve(profile, activity, target, intensity, pre, length, gainAt) {
|
|
150
|
+
if (!Number.isFinite(activity.level) || !intensity)
|
|
151
|
+
return [];
|
|
152
|
+
const keys = [];
|
|
153
|
+
const clipGain = clamp(target - activity.level, -15, 15) * intensity;
|
|
154
|
+
let first = 0;
|
|
155
|
+
for (const { from, to } of activity.phrases) {
|
|
156
|
+
while (profile.windows[first] && profile.windows[first].to - pre <= from)
|
|
157
|
+
first++;
|
|
158
|
+
const phraseLevels = [];
|
|
159
|
+
for (let i = first; i < profile.windows.length && profile.windows[i].from - pre < to; i++) {
|
|
160
|
+
const window = profile.windows[i];
|
|
161
|
+
phraseLevels.push(window.level +
|
|
162
|
+
20 *
|
|
163
|
+
Math.log10(gainAt(clamp((window.from + window.to) / 2 - pre, from, to))));
|
|
164
|
+
}
|
|
165
|
+
const difference = activity.level - percentile(phraseLevels, 0.65, activity.level);
|
|
166
|
+
// Quiet and loud expressive phrases retain their contrast.
|
|
167
|
+
const correction = Math.abs(difference) <= 9 ? clamp(difference * 0.45, -3, 3) : 0;
|
|
168
|
+
const value = Math.round((clipGain + correction * intensity) * 100) / 100;
|
|
169
|
+
if (!value)
|
|
170
|
+
continue;
|
|
171
|
+
const attack = Math.max(keys.at(-1)?.sample ?? 0, from - 2400);
|
|
172
|
+
const release = Math.min(length, to + 3600);
|
|
173
|
+
if (attack < from)
|
|
174
|
+
point(keys, attack, 0);
|
|
175
|
+
point(keys, from, value);
|
|
176
|
+
point(keys, to, value);
|
|
177
|
+
if (release > to)
|
|
178
|
+
point(keys, release, 0);
|
|
179
|
+
}
|
|
180
|
+
return keys;
|
|
181
|
+
}
|
|
182
|
+
export function musicCurve(activity, { depthDb, attackMs, holdMs, releaseMs, }, length) {
|
|
183
|
+
if (!depthDb)
|
|
184
|
+
return [];
|
|
185
|
+
const [attack, hold, release] = [attackMs, holdMs, releaseMs].map((ms) => Math.round(ms * 48));
|
|
186
|
+
const regions = [];
|
|
187
|
+
for (const span of activity
|
|
188
|
+
.slice()
|
|
189
|
+
.sort((a, b) => a.from - b.from || a.to - b.to)) {
|
|
190
|
+
const preceding = regions.at(-1);
|
|
191
|
+
if (preceding && span.from - attack <= preceding.to + hold + release)
|
|
192
|
+
preceding.to = Math.max(preceding.to, span.to);
|
|
193
|
+
else
|
|
194
|
+
regions.push({ ...span });
|
|
195
|
+
}
|
|
196
|
+
const keys = [];
|
|
197
|
+
for (const { from, to } of regions) {
|
|
198
|
+
if (from >= length)
|
|
199
|
+
break;
|
|
200
|
+
if (from > 0) {
|
|
201
|
+
const begin = Math.max(0, from - attack);
|
|
202
|
+
point(keys, begin, -depthDb * (1 - (from - begin) / attack));
|
|
203
|
+
}
|
|
204
|
+
point(keys, from, -depthDb);
|
|
205
|
+
const held = Math.min(length, to + hold);
|
|
206
|
+
point(keys, held, -depthDb);
|
|
207
|
+
if (held < length) {
|
|
208
|
+
const end = Math.min(length, held + release);
|
|
209
|
+
point(keys, end, -depthDb * (1 - (end - held) / release));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return keys;
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=dialogue-analysis.js.map
|
|
@@ -7,7 +7,7 @@ export { separateDialogue } from './dialogue.js';
|
|
|
7
7
|
export { MediaError, RenderCancelledError } from './process.js';
|
|
8
8
|
export type { MediaMetadata, MediaStream } from './probe.js';
|
|
9
9
|
export type { FrameResult } from './frame.js';
|
|
10
|
-
export { renderVideoTimeline, renderTimelineFrame, validateVideoTimeline, validateSubtitleBurnIn, renderCodecs, renderResolutions, } from './render.js';
|
|
10
|
+
export { renderVideoTimeline, renderTimelineFrame, analyzeTimelineAudioMix, validateVideoTimeline, validateSubtitleBurnIn, renderCodecs, renderResolutions, } from './render.js';
|
|
11
11
|
export type { VisualTimelineClip, VideoTimelineOptions, VideoTimelineResult, RenderControls, RenderCodec, RenderResolution, } from './render.js';
|
|
12
12
|
export { renderQualities, renderQualityProfiles } from '@opencut/shared';
|
|
13
13
|
export type { RenderQuality } from '@opencut/shared';
|
|
@@ -25,3 +25,5 @@ export { accountRenderFile, withRenderBudget, withDefaultRenderBudget, } from '.
|
|
|
25
25
|
export { hostRenderResources, sampleMemoryPressure } from './host-resources.js';
|
|
26
26
|
export { interpolationBackendId } from './interpolate.js';
|
|
27
27
|
export { enhancementBackendId } from './enhance.js';
|
|
28
|
+
export type { AudioMixReport, LoudnessMeasurement } from './audio-mastering.js';
|
|
29
|
+
export type { AudioMixCache } from './professional-mix.js';
|
|
@@ -5,7 +5,7 @@ export { inspectVideoToolboxWorkers } from './video-toolbox-workers.js';
|
|
|
5
5
|
export { inspectRenderMemory } from './process-memory.js';
|
|
6
6
|
export { separateDialogue } from './dialogue.js';
|
|
7
7
|
export { MediaError, RenderCancelledError } from './process.js';
|
|
8
|
-
export { renderVideoTimeline, renderTimelineFrame, validateVideoTimeline, validateSubtitleBurnIn, renderCodecs, renderResolutions, } from './render.js';
|
|
8
|
+
export { renderVideoTimeline, renderTimelineFrame, analyzeTimelineAudioMix, validateVideoTimeline, validateSubtitleBurnIn, renderCodecs, renderResolutions, } from './render.js';
|
|
9
9
|
export { renderQualities, renderQualityProfiles } from '@opencut/shared';
|
|
10
10
|
export { renderContactSheet } from './contact-sheet.js';
|
|
11
11
|
export { rasterizeTextLayer, validateEmbeddedFont } from './text.js';
|
|
Binary file
|
|
@@ -10,7 +10,8 @@ export interface MediaToolControl {
|
|
|
10
10
|
signal?: AbortSignal | undefined;
|
|
11
11
|
onStdout?: (chunk: Buffer) => void;
|
|
12
12
|
writesFile?: boolean;
|
|
13
|
+
onDiagnostics?: (diagnostics: string) => void;
|
|
13
14
|
}
|
|
14
15
|
export declare function localFile(file: string): Promise<string>;
|
|
15
16
|
export declare function sourceFileStamp(path: string): Promise<string>;
|
|
16
|
-
export declare function runMediaTool(tool:
|
|
17
|
+
export declare function runMediaTool(tool: string, args: string[], maxBuffer?: number, timeoutMs?: number, control?: MediaToolControl): Promise<Buffer>;
|
|
@@ -35,7 +35,7 @@ export async function sourceFileStamp(path) {
|
|
|
35
35
|
return [info.dev, info.ino, info.size, info.mtimeNs, info.ctimeNs].join(':');
|
|
36
36
|
}
|
|
37
37
|
// execFile passes arguments directly, without shell expansion. Bound both runtime
|
|
38
|
-
// and buffered output
|
|
38
|
+
// and buffered output, and close stdin so tools cannot wait for user input.
|
|
39
39
|
export async function runMediaTool(tool, args, maxBuffer = 4 * 1024 * 1024, timeoutMs = 60_000, control) {
|
|
40
40
|
checkRenderSignal(control?.signal);
|
|
41
41
|
const command = renderToolCommand(tool, args, control?.writesFile);
|
|
@@ -79,7 +79,10 @@ export async function runMediaTool(tool, args, maxBuffer = 4 * 1024 * 1024, time
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
if (error && 'code' in error && error.code === 'ENOENT') {
|
|
82
|
-
reject(new MediaError(`Required executable '${tool}' was not found on PATH
|
|
82
|
+
reject(new MediaError(`Required executable '${tool}' was not found on PATH.` +
|
|
83
|
+
(tool === 'ffmpeg' || tool === 'ffprobe'
|
|
84
|
+
? ' Install FFmpeg/ffprobe manually to use media commands.'
|
|
85
|
+
: ''), { cause: error }));
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
const diagnostics = stderr.toString('utf8').trim();
|
|
@@ -90,11 +93,17 @@ export async function runMediaTool(tool, args, maxBuffer = 4 * 1024 * 1024, time
|
|
|
90
93
|
}));
|
|
91
94
|
return;
|
|
92
95
|
}
|
|
93
|
-
if (error || diagnostics) {
|
|
96
|
+
if (error || (diagnostics && !control?.onDiagnostics)) {
|
|
94
97
|
reject(new MediaError(`${tool} failed: ${diagnostics || error?.message || 'unknown execution failure'}`, { cause: error }));
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
|
-
|
|
100
|
+
try {
|
|
101
|
+
control?.onDiagnostics?.(diagnostics);
|
|
102
|
+
resolve(stdout);
|
|
103
|
+
}
|
|
104
|
+
catch (cause) {
|
|
105
|
+
reject(cause);
|
|
106
|
+
}
|
|
98
107
|
});
|
|
99
108
|
if (!closed)
|
|
100
109
|
untrack = trackRenderProcess(child.pid, (error) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ProfessionalMix } from '@opencut/shared';
|
|
2
|
+
import type { AudioRenderClip } from './audio-graph.js';
|
|
3
|
+
import type { MediaMetadata } from './probe.js';
|
|
4
|
+
import type { VideoTimelineOptions } from './render.js';
|
|
5
|
+
export interface AudioMixCache {
|
|
6
|
+
materialize(key: string, encode: (path: string) => Promise<MediaMetadata>): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
type SourceReader = (clip: AudioRenderClip) => Promise<MediaMetadata>;
|
|
9
|
+
export declare function prepareProfessionalMix(options: VideoTimelineOptions, mix: ProfessionalMix, folder: string, readSource: SourceReader, { base, from, to }: {
|
|
10
|
+
base: number;
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
path: string;
|
|
15
|
+
report: {
|
|
16
|
+
automation: {
|
|
17
|
+
dialogue: {
|
|
18
|
+
[k: string]: import("@opencut/shared").MixGainPoint[];
|
|
19
|
+
};
|
|
20
|
+
music: import("@opencut/shared").MixGainPoint[];
|
|
21
|
+
};
|
|
22
|
+
target: {
|
|
23
|
+
integratedLufs: number;
|
|
24
|
+
truePeakDbtp: number;
|
|
25
|
+
loudnessRange: number;
|
|
26
|
+
};
|
|
27
|
+
input: import("./audio-mastering.js").LoudnessMeasurement;
|
|
28
|
+
output: import("./audio-mastering.js").LoudnessMeasurement;
|
|
29
|
+
comparison: "after" | "before";
|
|
30
|
+
normalization: "linear" | "dynamic" | "none";
|
|
31
|
+
warnings: string[];
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
export {};
|