@aicopycoders/exodus 2026.11.1200-beta.22 → 2026.11.1200-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -114,6 +114,8 @@ export function endCardLayersOf(
|
|
|
114
114
|
|
|
115
115
|
/** #4585: the seconds between the last heard word's end and the end card. */
|
|
116
116
|
export const END_CARD_AFTER_VOICE_SEC: number;
|
|
117
|
+
/** COP-353: the worker's silence probe numbers (media-probe.ts SILENCE_NOISE, SILENCE_MIN_DURATION_SEC), at which the cut reads the voice's silences. */
|
|
118
|
+
export const GUARD_SILENCE: { noise: string; minSec: number };
|
|
117
119
|
|
|
118
120
|
/** #4585: the end card on the cut, holding the last scene's picture under it; throws VoiceUnderEndCardRefusal when it would cover a word. */
|
|
119
121
|
export function placeEndCard(
|
|
@@ -299,7 +301,35 @@ export interface CutPace {
|
|
|
299
301
|
paceSpeed?: number;
|
|
300
302
|
/** COP-300: the finished cut was checked against its own sound (cutSync). */
|
|
301
303
|
captionCheck?: true;
|
|
304
|
+
/** COP-353: with cleanVoice, the cut's own named chain in its place (VOICE_SOUNDS). */
|
|
305
|
+
voiceSound?: "phone" | "memo" | "raw";
|
|
306
|
+
/** COP-354: the room sound under the whole film, a bed the cut makes itself (ROOM_BEDS), or none. */
|
|
307
|
+
roomSound?: "none" | "room" | "kitchen" | "car" | "outside";
|
|
308
|
+
/** COP-355: one of Luke's pause levels, by name, in place of jumpCut (PAUSE_TRIMS). */
|
|
309
|
+
pauseTrim?: "light" | "medium" | "hard";
|
|
310
|
+
/** COP-355: a cut is added where this many seconds pass with none, by name (ADDED_CUTS). */
|
|
311
|
+
addedCuts?: "7" | "5" | "3.5";
|
|
312
|
+
/** COP-355: with addedCuts, the script lines no added cut falls inside. */
|
|
313
|
+
wholeLines?: string[];
|
|
302
314
|
};
|
|
315
|
+
/**
|
|
316
|
+
* COP-354: the room sound the cut laid: none, or a bed with its levels (the voice's integrated loudness after its
|
|
317
|
+
* chain, the bed's RMS before its gain, the gain, how far under the voice). The voice's silences the worker's last
|
|
318
|
+
* guard reads under a bed are `voiceSilences` (a bed fills every silence of the film).
|
|
319
|
+
*/
|
|
320
|
+
room?: {
|
|
321
|
+
sound: "none" | "room" | "kitchen" | "car" | "outside";
|
|
322
|
+
voiceLufs?: number;
|
|
323
|
+
bedRmsDb?: number;
|
|
324
|
+
gainDb?: number;
|
|
325
|
+
underDb?: number;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* COP-353: present when a picked voice chain was used (COP-354: or a room bed laid): the voice's silences as today's
|
|
329
|
+
* cut would deliver it, on the film's clock, which the worker's last guard reads in place of the film's (the chain lifts
|
|
330
|
+
* the film's quiet floor; a bed fills it).
|
|
331
|
+
*/
|
|
332
|
+
voiceSilences?: { start: number; end: number; duration: number }[];
|
|
303
333
|
/**
|
|
304
334
|
* `limited`: limitPeaks' limiter ran after the loudness pass. #4573: `limitedAgain` times it ran again lower, from
|
|
305
335
|
* the same mix, because the finished file was over -1 dBTP; `limit` is the ceiling the kept cut was made at.
|
|
@@ -487,6 +517,11 @@ export interface FirstCut {
|
|
|
487
517
|
sound?: CutSound;
|
|
488
518
|
/** The music-only master's path, when one was made. */
|
|
489
519
|
musicOnlyMaster?: string;
|
|
520
|
+
/**
|
|
521
|
+
* COP-355, addedCuts: where the cut changed a take's framing inside it, in seconds on the delivered film's clock;
|
|
522
|
+
* present only with the cuts row on. The worker's last guard joins a freeze that one splits (auto-cut.ts withFramingJoins).
|
|
523
|
+
*/
|
|
524
|
+
framingChangesSec?: number[];
|
|
490
525
|
/** Present only when the manifest asked for the measured map.
|
|
491
526
|
* Authored picture time is reserved once per take; only its final split piece
|
|
492
527
|
* may extend, so earlier pieces never replay the resumed piece's source audio.
|
|
@@ -242,6 +242,52 @@ export function jumpCutSpan(endSec, startSec, jump = JUMP_CUT) {
|
|
|
242
242
|
return e > s ? { s, e } : null;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
/**
|
|
246
|
+
* pauseTrim (COP-355, a run's saved sheet: Luke's three pause levels, by name): jumpCut with these numbers in place of
|
|
247
|
+
* its own, so any pause over maxGap between two heard words is cut to about keepAfter plus keepBefore. The pauses
|
|
248
|
+
* jumpCut keeps whole (one the script writes in, one a direction asks for, a reaction's beat) stay whole here too.
|
|
249
|
+
*/
|
|
250
|
+
export const PAUSE_TRIMS = {
|
|
251
|
+
light: { maxGap: 0.6, keepAfter: 0.15, keepBefore: 0.15 },
|
|
252
|
+
medium: { maxGap: 0.4, keepAfter: 0.1, keepBefore: 0.1 },
|
|
253
|
+
hard: { maxGap: 0.25, keepAfter: 0.05, keepBefore: 0.05 },
|
|
254
|
+
};
|
|
255
|
+
const PAUSE_LEVELS = new Set(Object.values(PAUSE_TRIMS));
|
|
256
|
+
/**
|
|
257
|
+
* pauseTrim: the fade of a take's sound at each join inside it, in and out, as Luke's own finish fades its joins. It
|
|
258
|
+
* changes no length. Today's trim and kept pauses have none.
|
|
259
|
+
*/
|
|
260
|
+
const PAUSE_JOIN_FADE_SEC = 0.012;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* addedCuts (COP-355, a run's saved sheet: Luke's locked finish, by name): the longest a take may run with no cut, in
|
|
264
|
+
* seconds on its own clock before the speed-up. See addedCutPlan for where a cut goes. `ADDED_CUT`: a removal this
|
|
265
|
+
* long or longer (`realSec`) is a cut already; an added cut sits at least `clearSec` from both ends of its stretch;
|
|
266
|
+
* the other framing is `zoom` times the take's own, or its own divided by `zoom` when the take is punched in past
|
|
267
|
+
* `tightPast`, centred left to right with `top` of the spare height above it.
|
|
268
|
+
*/
|
|
269
|
+
export const ADDED_CUTS = { "7": 7, "5": 5, "3.5": 3.5 };
|
|
270
|
+
export const ADDED_CUT = { realSec: 0.3, clearSec: 1.2, zoom: 1.08, tightPast: 1.1, top: 0.42 };
|
|
271
|
+
/** The ffmpeg filters an added cut's picture uses (buildFfmpegArgs), each in ffmpeg 5.1, the worker's. */
|
|
272
|
+
export const ADDED_CUT_FILTERS = ["split", "trim", "setpts", "scale", "crop", "setsar", "concat"];
|
|
273
|
+
/**
|
|
274
|
+
* addedCuts: a framing change this many frames or fewer from another, or from a take's edge, is left out (a piece of a
|
|
275
|
+
* frame or two flashes, and at a speed over 1 the join of the pieces can lose a frame); a take that would start in a
|
|
276
|
+
* zoom within FRAMING_SAME_WITHIN of the one the take before it ends in starts in its other framing (the same picture
|
|
277
|
+
* across a join, #3304).
|
|
278
|
+
*/
|
|
279
|
+
const FRAMING_MIN_FRAMES = 6;
|
|
280
|
+
const FRAMING_SAME_WITHIN = 0.03;
|
|
281
|
+
/** addedCuts: framingChangeTimes leaves out a change this many frames or fewer from a cutaway's edges (1/24 s, and the frame its edge can land from its clock). */
|
|
282
|
+
const FRAMING_NEAR_CUTAWAY = 2;
|
|
283
|
+
/** A name of `table`, as a string, or null; never one of an object's own words ("constructor"). */
|
|
284
|
+
const nameIn = (table, value) => (typeof value === "string" && Object.prototype.hasOwnProperty.call(table, value) ? value : null);
|
|
285
|
+
/** addedCuts' `wholeLines`, the script line ids the worker marked, as finishingOf keeps them: none when there are none. */
|
|
286
|
+
function wholeLinesOf(raw) {
|
|
287
|
+
const ids = Array.isArray(raw) ? raw.filter((id) => typeof id === "string" && id !== "") : [];
|
|
288
|
+
return ids.length > 0 ? { wholeLines: ids } : {};
|
|
289
|
+
}
|
|
290
|
+
|
|
245
291
|
/** Plan 14's on/off cut checks, each read only with cutChecks; paceCheck also carries its numbers. */
|
|
246
292
|
const PLAN_14_CHECKS = ["floorCheck", "flashCheck", "levelStepCheck", "voFitCheck", "dashGapCheck", "nameCheck"];
|
|
247
293
|
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -289,6 +335,16 @@ export function finishingOf(manifest) {
|
|
|
289
335
|
...(f.pacePass === true && paceSpeedOk(f.paceSpeed) ? { paceSpeed: f.paceSpeed } : {}),
|
|
290
336
|
...(f.captionCheck === true ? { captionCheck: true } : {}),
|
|
291
337
|
...(f.keepPauses === true ? { keepPauses: true } : {}),
|
|
338
|
+
// COP-353: a name of the cut's own chains only, and only beside the chain it stands in place of.
|
|
339
|
+
...(f.cleanVoice === true && typeof f.voiceSound === "string" && Object.hasOwn(VOICE_SOUNDS, f.voiceSound)
|
|
340
|
+
? { voiceSound: f.voiceSound } : {}),
|
|
341
|
+
// COP-354: none, or the name of one of the cut's own beds.
|
|
342
|
+
...(typeof f.roomSound === "string" && (f.roomSound === "none" || Object.hasOwn(ROOM_BEDS, f.roomSound)) ? { roomSound: f.roomSound } : {}),
|
|
343
|
+
// COP-355: a saved sheet's pause level and cuts added, each by its name; the lines no added cut falls inside with it.
|
|
344
|
+
...(nameIn(PAUSE_TRIMS, f.pauseTrim) ? { pauseTrim: f.pauseTrim } : {}),
|
|
345
|
+
...(nameIn(ADDED_CUTS, f.addedCuts) ? { addedCuts: f.addedCuts, ...wholeLinesOf(f.wholeLines) } : {}),
|
|
346
|
+
// COP-356: the card as a headline at the top (headlineCards), a name only the worker writes from a run's sheet.
|
|
347
|
+
...(on.cards && f.cardPlace === "top" ? { cardPlace: "top" } : {}),
|
|
292
348
|
};
|
|
293
349
|
if (!Object.values(on).some(Boolean) && Object.keys(added).length === 0) return null;
|
|
294
350
|
const target = f.targetSeconds;
|
|
@@ -330,6 +386,107 @@ export const VOICE_CLEAN =
|
|
|
330
386
|
"highpass=f=90,afftdn=nr=8:nf=-38,deesser=i=0.35,acompressor=threshold=0.125:ratio=2.5:attack=8:release=150:makeup=1.5";
|
|
331
387
|
export const UNDER_VOICE = { db: -6, highpass: 60, lowpass: 9000, duck: { threshold: 0.03, ratio: 5, attack: 15, release: 300 } };
|
|
332
388
|
const CLEAN_FILTERS = ["highpass", "lowpass", "afftdn", "deesser", "acompressor", "sidechaincompress"];
|
|
389
|
+
/**
|
|
390
|
+
* COP-353, voiceSound: how the voice sounds, a run's saved sheet's pick, which the worker writes beside cleanVoice as
|
|
391
|
+
* a name: the cut runs only its own chains, never a filter graph from a manifest. The chain stands in VOICE_CLEAN's
|
|
392
|
+
* place, on the joined voice before the beds are ducked under it, and the loudness pass sets the film's level after
|
|
393
|
+
* it, as it does today. phone: the lows under 120 Hz and the highs over 7.5 kHz cut, a fast 4:1 compressor and a soft
|
|
394
|
+
* clip, with no noise reduction or de-essing before it. memo: a narrow band from 300 Hz to 3.4 kHz, a hard 8:1
|
|
395
|
+
* compressor, 4 dB more and a soft clip. raw: the voice as filmed. The numbers are Luke's tested chains (his kit's post
|
|
396
|
+
* tests) without his gain back to a level and his limiter, which the loudness pass and its limiter do here. Every
|
|
397
|
+
* filter is in ffmpeg 5.1, the worker's (exodus/__tests__/first-cut-sheet-voice.test.ts lists them).
|
|
398
|
+
*/
|
|
399
|
+
export const VOICE_SOUNDS = {
|
|
400
|
+
phone: "highpass=f=120,lowpass=f=7500,acompressor=threshold=-24dB:ratio=4:attack=5:release=120:makeup=2,asoftclip=type=tanh",
|
|
401
|
+
memo: "highpass=f=300,lowpass=f=3400,acompressor=threshold=-32dB:ratio=8:attack=3:release=80:makeup=4,volume=4dB,asoftclip=type=tanh",
|
|
402
|
+
raw: "anull",
|
|
403
|
+
};
|
|
404
|
+
/** The filters a chain runs, by name. */
|
|
405
|
+
const chainFilters = (chain) => chain.split(",").map((part) => part.split("=")[0]);
|
|
406
|
+
/** The filters the duck under the voice runs, whichever chain is on it (UNDER_VOICE). */
|
|
407
|
+
const UNDER_FILTERS = ["highpass", "lowpass", "sidechaincompress"];
|
|
408
|
+
/**
|
|
409
|
+
* COP-354, roomSound: the room sound under the whole film, a run's saved sheet's pick, which the worker writes as a
|
|
410
|
+
* name ("none", "room", "kitchen", "car" or "outside"): the cut runs only its own beds, never a graph from a manifest.
|
|
411
|
+
* Each bed is made here by ffmpeg from seeded noise and tones (no sound file, no vendor), for the film's whole length
|
|
412
|
+
* before the speed step, and mixed after the join and the pause trims, so it runs on under every cut and every take's
|
|
413
|
+
* own floor. It is not ducked: a room does not go quiet when someone talks. Its RMS is set ROOM_UNDER_DB under the
|
|
414
|
+
* voice's integrated loudness after its chain, measured in one extra pass of the voice alone; the loudness pass then
|
|
415
|
+
* moves both together. It fades in and out over ROOM_FADE_SEC. With a bed, or with "none", the cut's own faint brown
|
|
416
|
+
* bed (ROOM_TONE) is not laid. The beds are Luke's made-up placeholders, synthesised the same way (his kit's post
|
|
417
|
+
* tests), at 48 kHz; the times of the kitchen's clinks and the outside's chirps come from a seeded generator, so one
|
|
418
|
+
* folder cuts the same bed every time. Each clink and chirp is an if() that ffmpeg works out only in its own moment:
|
|
419
|
+
* as a product, a clink's exp() long before its moment overflows, and 0 times infinity silences the bed up to there on
|
|
420
|
+
* a film over about 22 s; it is also ten times faster to make.
|
|
421
|
+
*/
|
|
422
|
+
export const ROOM_UNDER_DB = 27;
|
|
423
|
+
export const ROOM_FADE_SEC = 0.08;
|
|
424
|
+
const ROOM_RATE = 48000;
|
|
425
|
+
|
|
426
|
+
/** A seeded generator of numbers in [0, 1) (mulberry32): the same seed gives the same numbers on every machine. */
|
|
427
|
+
function seeded(seed) {
|
|
428
|
+
let a = seed >>> 0;
|
|
429
|
+
return () => {
|
|
430
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
431
|
+
let t = a;
|
|
432
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
433
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
434
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** Moments for a sound now and then: the first between 1.5 s and `every`, then every 0.6 to 1.5 times `every`. */
|
|
439
|
+
export function roomMoments(seconds, every, seed) {
|
|
440
|
+
const next = seeded(seed);
|
|
441
|
+
const between = (lo, hi) => lo + (hi - lo) * next();
|
|
442
|
+
const out = [];
|
|
443
|
+
for (let t = between(1.5, every); t < seconds - 1; t += between(every * 0.6, every * 1.5)) out.push(Math.round(t * 100) / 100);
|
|
444
|
+
return out;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const noise = (color, amplitude, seed, seconds) => `anoisesrc=d=${seconds}:c=${color}:r=${ROOM_RATE}:a=${amplitude}:seed=${seed}`;
|
|
448
|
+
const tone = (expr, seconds) => `aevalsrc=exprs='${expr}':s=${ROOM_RATE}:d=${seconds}`;
|
|
449
|
+
const clinks = (times, f1, f2, decay = 32) =>
|
|
450
|
+
times.map((k) => `if(gte(t,${k})*lt(t,${(k + 0.4).toFixed(2)}),exp(-${decay}*(t-${k}))*(sin(2*PI*${f1}*(t-${k}))+0.5*sin(2*PI*${f2}*(t-${k}))),0)`).join("+") || "0";
|
|
451
|
+
const chirps = (times) =>
|
|
452
|
+
times.flatMap((k) => [0, 1, 2].map((q) => {
|
|
453
|
+
const a = (k + q * 0.16).toFixed(2);
|
|
454
|
+
return `if(between(t,${a},${(k + q * 0.16 + 0.1).toFixed(2)}),sin(2*PI*(${3000 + 400 * q}+9000*(t-${a}))*(t-${a}))*pow(sin(PI*(t-${a})/0.1),2),0)`;
|
|
455
|
+
})).join("+") || "0";
|
|
456
|
+
|
|
457
|
+
/** Each bed: its sources and the graph that joins them into [a], for a film of `seconds`. */
|
|
458
|
+
export const ROOM_BEDS = {
|
|
459
|
+
room: (d) => ({
|
|
460
|
+
sources: [noise("brown", 0.6, 3, d), tone("0.02*sin(2*PI*60*t)", d)],
|
|
461
|
+
graph: "[0:a]highpass=f=70,lowpass=f=700[a0];[a0][1:a]amix=inputs=2:normalize=0[a]",
|
|
462
|
+
}),
|
|
463
|
+
kitchen: (d) => ({
|
|
464
|
+
sources: [
|
|
465
|
+
tone("(1+0.06*sin(2*PI*0.31*t))*(0.30*sin(2*PI*60*t)+0.22*sin(2*PI*120*t)+0.12*sin(2*PI*180*t)+0.06*sin(2*PI*240*t)+0.03*sin(2*PI*360*t))", d),
|
|
466
|
+
noise("brown", 0.35, 4, d),
|
|
467
|
+
tone(`0.5*(${clinks(roomMoments(Number(d), 6.5, 21), 2350, 3720)})`, d),
|
|
468
|
+
],
|
|
469
|
+
graph: "[1:a]highpass=f=80,lowpass=f=900[a1];[0:a][a1][2:a]amix=inputs=3:normalize=0[a]",
|
|
470
|
+
}),
|
|
471
|
+
car: (d) => ({
|
|
472
|
+
sources: [noise("brown", 0.9, 5, d), noise("pink", 0.5, 6, d)],
|
|
473
|
+
graph: "[0:a]lowpass=f=160[a0];[1:a]highpass=f=180,lowpass=f=650,volume=volume='0.25+0.75*pow(sin(PI*t/9.5),6)':eval=frame[a1];[a0][a1]amix=inputs=2:normalize=0[a]",
|
|
474
|
+
}),
|
|
475
|
+
outside: (d) => ({
|
|
476
|
+
sources: [noise("pink", 0.6, 8, d), tone(`0.35*(${chirps(roomMoments(Number(d), 4.5, 31))})`, d)],
|
|
477
|
+
graph: "[0:a]highpass=f=150,lowpass=f=1400,volume=volume='0.45+0.55*pow(sin(PI*t/11),2)':eval=frame[a0];[a0][1:a]amix=inputs=2:normalize=0[a]",
|
|
478
|
+
}),
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
/** The ffmpeg command that makes a bed for `seconds` into `out` (mono, 48 kHz, 32-bit float: a peak over full scale is kept for the gain). */
|
|
482
|
+
export function roomBedArgs(name, seconds, out) {
|
|
483
|
+
const { sources, graph } = ROOM_BEDS[name](seconds.toFixed(3));
|
|
484
|
+
return [
|
|
485
|
+
"-y", "-hide_banner", "-loglevel", "error",
|
|
486
|
+
...sources.flatMap((source) => ["-f", "lavfi", "-i", source]),
|
|
487
|
+
"-filter_complex", graph, "-map", "[a]", "-ac", "1", "-ar", String(ROOM_RATE), "-c:a", "pcm_f32le", out,
|
|
488
|
+
];
|
|
489
|
+
}
|
|
333
490
|
const SEGMENT_LUFS = -16;
|
|
334
491
|
/** A voice at or under this is no level to set a sound against. */
|
|
335
492
|
const VOICE_FLOOR_LUFS = -60;
|
|
@@ -1015,7 +1172,10 @@ export function sentenceGapCuts(words, lines, levels = null, lineGap = null, jum
|
|
|
1015
1172
|
// between the kept length and the longest allowed.
|
|
1016
1173
|
const back = (t) => (sound && t > sound.s ? t + removed : t);
|
|
1017
1174
|
const [keepAfter, keepBefore] = jumped ? [jump.keepAfter, jump.keepBefore] : [gapKeep / 2, gapKeep / 2];
|
|
1018
|
-
const
|
|
1175
|
+
const after = ceilFrame(earlier.e + keepAfter);
|
|
1176
|
+
// COP-355: at one of Luke's pause levels, a sound that starts inside the air kept after the word takes that air
|
|
1177
|
+
// with it: the silence's cut starts with the sound's, so no piece of the pause of a frame or two is left between them.
|
|
1178
|
+
const s = jumped && PAUSE_LEVELS.has(jump) && sound && sound.s < after - 1e-6 ? sound.s : back(after);
|
|
1019
1179
|
const e = back(floorFrame(later.s - removed - keepBefore));
|
|
1020
1180
|
if (e > s) spans.push({ s, e });
|
|
1021
1181
|
}
|
|
@@ -1670,6 +1830,231 @@ export function paceZooms(spine, speed) {
|
|
|
1670
1830
|
return `pacePass: the cut plays at ${speed}x and ${zoomed} piece${zoomed === 1 ? "" : "s"} zoom ${PACE_PASS.zoom}x`;
|
|
1671
1831
|
}
|
|
1672
1832
|
|
|
1833
|
+
/** A heard word that ends on a comma (a closing quote or bracket may follow it). */
|
|
1834
|
+
const HEARD_COMMA = /,["'”’)\]]*$/;
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* addedCuts (COP-355): Luke's locked rule for one take, on its own clock before the speed-up. `realCuts` are the
|
|
1838
|
+
* cuts the take holds already; its two edges count as cuts too. `whole` holds the
|
|
1839
|
+
* [start, end] spans of the lines no cut may fall inside. A place is the middle of the silence after a heard word that
|
|
1840
|
+
* ends a sentence or has a comma, when it is not inside a whole line. While the longest stretch between two cuts runs
|
|
1841
|
+
* over `everySec`, a cut goes at a place in it at least ADDED_CUT.clearSec from both its ends: a sentence's end before
|
|
1842
|
+
* a comma, then the place nearest its middle. When that stretch has no such place, no more is added. Returns the times
|
|
1843
|
+
* of the cuts added, in order, and the longest stretch left with no cut.
|
|
1844
|
+
*/
|
|
1845
|
+
export function addedCutPlan({ words, seconds, realCuts = [], joins = [], everySec, whole = [] }) {
|
|
1846
|
+
const places = [];
|
|
1847
|
+
for (let i = 0; i + 1 < words.length; i++) {
|
|
1848
|
+
const rank = heardSentenceEnd(words[i].w) ? 0 : HEARD_COMMA.test(String(words[i].w ?? "")) ? 1 : null;
|
|
1849
|
+
if (rank === null) continue;
|
|
1850
|
+
// A pause that holds a cut already (`joins`, one too short to count) has its place on that cut's join, so the
|
|
1851
|
+
// framing changes with the picture's jump and not a few frames after it.
|
|
1852
|
+
const join = joins.filter((t) => t >= words[i].e - 1e-6 && t <= words[i + 1].s + 1e-6).at(-1);
|
|
1853
|
+
const t = join ?? (words[i].e + words[i + 1].s) / 2;
|
|
1854
|
+
if (!(t > 0 && t < seconds) || whole.some(([s, e]) => t > s && t < e)) continue;
|
|
1855
|
+
places.push({ t, rank });
|
|
1856
|
+
}
|
|
1857
|
+
const added = [];
|
|
1858
|
+
const longestOf = () => {
|
|
1859
|
+
const marks = [...new Set([0, ...realCuts, ...added, seconds])].sort((a, b) => a - b);
|
|
1860
|
+
return marks.slice(1).reduce(
|
|
1861
|
+
(best, to, k) => (to - marks[k] > best.length + 1e-9 ? { length: to - marks[k], from: marks[k], to } : best),
|
|
1862
|
+
{ length: 0, from: 0, to: 0 },
|
|
1863
|
+
);
|
|
1864
|
+
};
|
|
1865
|
+
for (let gap = longestOf(); gap.length > everySec + 1e-9; gap = longestOf()) {
|
|
1866
|
+
const mid = (gap.from + gap.to) / 2;
|
|
1867
|
+
const inside = places.filter((p) =>
|
|
1868
|
+
p.t >= gap.from + ADDED_CUT.clearSec - 1e-9 && p.t <= gap.to - ADDED_CUT.clearSec + 1e-9 &&
|
|
1869
|
+
added.every((t) => Math.abs(p.t - t) > 0.01));
|
|
1870
|
+
if (inside.length === 0) break;
|
|
1871
|
+
const best = inside.reduce((a, b) =>
|
|
1872
|
+
b.rank < a.rank || (b.rank === a.rank && Math.abs(b.t - mid) < Math.abs(a.t - mid) - 1e-9) ? b : a);
|
|
1873
|
+
added.push(best.t);
|
|
1874
|
+
}
|
|
1875
|
+
return { added: added.map(r6).sort((a, b) => a - b), longest: r6(longestOf().length) };
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* addedCuts: the cuts a talking segment holds already, on its own clock: each place a pause or a sound was cut out of
|
|
1880
|
+
* it, and how much went. The removals of one pause (no heard word between them) are one cut, at the last of them, where
|
|
1881
|
+
* the next word's picture starts. A cut counts (Luke's) where ADDED_CUT.realSec or more went.
|
|
1882
|
+
*/
|
|
1883
|
+
function breaksOf(seg) {
|
|
1884
|
+
const breaks = [];
|
|
1885
|
+
let removed = 0;
|
|
1886
|
+
for (const c of [...(seg.cuts ?? [])].sort((a, b) => a.s - b.s)) {
|
|
1887
|
+
const t = c.s - removed - (seg.inSec ?? 0);
|
|
1888
|
+
removed += c.e - c.s;
|
|
1889
|
+
const prev = breaks.at(-1);
|
|
1890
|
+
if (prev && !seg.words.some((w) => w.s > prev.t + 1e-6 && w.s < t - 1e-6)) Object.assign(prev, { t, length: prev.length + c.e - c.s });
|
|
1891
|
+
else breaks.push({ t, length: c.e - c.s });
|
|
1892
|
+
}
|
|
1893
|
+
return breaks.filter((b) => b.t > 1e-6 && b.t < seg.seconds - 1e-6).map((b) => ({ t: r6(b.t), counts: b.length >= ADDED_CUT.realSec - 1e-6 }));
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* addedCuts: the frames where a take's framing changes, from the times of its cuts: on whole frames, in order, none
|
|
1898
|
+
* within FRAMING_MIN_FRAMES of the one before it or of the take's two edges (`frames` long).
|
|
1899
|
+
*/
|
|
1900
|
+
export function framingFrames(times, frames) {
|
|
1901
|
+
const kept = [];
|
|
1902
|
+
for (const f of [...new Set(times.map((t) => Math.round(t * FPS)))].sort((a, b) => a - b)) {
|
|
1903
|
+
if (f < FRAMING_MIN_FRAMES || f > frames - FRAMING_MIN_FRAMES) continue;
|
|
1904
|
+
if (kept.length > 0 && f - kept.at(-1) < FRAMING_MIN_FRAMES) continue;
|
|
1905
|
+
kept.push(f);
|
|
1906
|
+
}
|
|
1907
|
+
return kept;
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
/** addedCuts: where each script line of a talking segment is heard, [start, end] on the segment's clock, by line id. */
|
|
1911
|
+
function lineSpans(seg, scriptLines) {
|
|
1912
|
+
const lines = seg.lineIds.map((id) => scriptWords(scriptLines.get(id)?.text));
|
|
1913
|
+
const spans = new Map();
|
|
1914
|
+
if (!lines.some((l) => l.length > 0)) return spans;
|
|
1915
|
+
const lineOf = lines.flatMap((ws, j) => ws.map(() => seg.lineIds[j]));
|
|
1916
|
+
const put = (i, s, e) => {
|
|
1917
|
+
const was = spans.get(lineOf[i]);
|
|
1918
|
+
spans.set(lineOf[i], was ? [Math.min(was[0], s), Math.max(was[1], e)] : [s, e]);
|
|
1919
|
+
};
|
|
1920
|
+
const aligned = alignScript(seg.words, lines.flat());
|
|
1921
|
+
if (aligned) {
|
|
1922
|
+
const { expected, heard, heardTokenOf } = aligned;
|
|
1923
|
+
heardTokenOf.forEach((h, e) => put(expected.sourceIndex[e], seg.words[heard.sourceIndex[h]].s, seg.words[heard.lastSourceIndex[h]].e));
|
|
1924
|
+
return spans;
|
|
1925
|
+
}
|
|
1926
|
+
// COP-311's reading when the script is not heard whole and in order: each script word on what was heard in its place.
|
|
1927
|
+
const { expected, times } = scriptTimes(seg.words, lines.flat());
|
|
1928
|
+
const timed = new Set();
|
|
1929
|
+
times.forEach((time, e) => {
|
|
1930
|
+
if (!time) return;
|
|
1931
|
+
put(expected.sourceIndex[e], time[0], time[1]);
|
|
1932
|
+
timed.add(expected.sourceIndex[e]);
|
|
1933
|
+
});
|
|
1934
|
+
// A line whose first or last word was not timed may still be spoken past its timed words: its span runs back to the
|
|
1935
|
+
// line before's last heard word and on to the next line's first (or the take's edges), so no cut lands in that part.
|
|
1936
|
+
const heard = new Map(spans);
|
|
1937
|
+
const words = new Set(expected.sourceIndex);
|
|
1938
|
+
let from = 0;
|
|
1939
|
+
seg.lineIds.forEach((id, j) => {
|
|
1940
|
+
const own = [...words].filter((i) => i >= from && i < from + lines[j].length);
|
|
1941
|
+
from += lines[j].length;
|
|
1942
|
+
const span = heard.get(id);
|
|
1943
|
+
if (!span || own.length === 0) return;
|
|
1944
|
+
const before = seg.lineIds.slice(0, j).map((k) => heard.get(k)).filter(Boolean).at(-1);
|
|
1945
|
+
const after = seg.lineIds.slice(j + 1).map((k) => heard.get(k)).find(Boolean);
|
|
1946
|
+
spans.set(id, [
|
|
1947
|
+
timed.has(Math.min(...own)) ? span[0] : (before?.[1] ?? 0),
|
|
1948
|
+
timed.has(Math.max(...own)) ? span[1] : (after?.[0] ?? seg.seconds),
|
|
1949
|
+
]);
|
|
1950
|
+
});
|
|
1951
|
+
return spans;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* addedCuts: each talking segment's cuts added (addedCutPlan), and `seg.framing`, the frames of its own clock where its
|
|
1956
|
+
* framing changes: at every cut it counts, those it held and those added. A line marked whole that its words do not
|
|
1957
|
+
* show is taken to run through the whole take, so nothing is added there. Answers the cut's note.
|
|
1958
|
+
*/
|
|
1959
|
+
function placeAddedCuts(spine, scriptLines, everySec, wholeLines) {
|
|
1960
|
+
const whole = new Set(wholeLines);
|
|
1961
|
+
let count = 0;
|
|
1962
|
+
let longest = 0;
|
|
1963
|
+
for (const seg of spine) {
|
|
1964
|
+
if (seg.source !== "clip" || seg.audio !== "clip" || !seg.words?.length || seg.reaction || seg.wholeVoice) continue;
|
|
1965
|
+
const spans = lineSpans(seg, scriptLines);
|
|
1966
|
+
const held = (seg.lineIds ?? []).filter((id) => whole.has(id)).map((id) => spans.get(id) ?? [0, seg.seconds]);
|
|
1967
|
+
const breaks = breaksOf(seg);
|
|
1968
|
+
const realCuts = breaks.filter((b) => b.counts).map((b) => b.t);
|
|
1969
|
+
const plan = addedCutPlan({ words: seg.words, seconds: seg.seconds, realCuts, joins: breaks.map((b) => b.t), everySec, whole: held });
|
|
1970
|
+
const frames = Math.round(seg.seconds * FPS);
|
|
1971
|
+
const framing = framingFrames([...realCuts, ...plan.added], frames);
|
|
1972
|
+
const added = plan.added.filter((t) => framing.includes(Math.round(t * FPS)));
|
|
1973
|
+
const edges = [0, ...framing, frames];
|
|
1974
|
+
longest = Math.max(longest, ...edges.slice(1).map((f, k) => (f - edges[k]) / FPS));
|
|
1975
|
+
// Set on every take the row reaches, even with no change, so its join with the take before it is seen to (framingAtJoins).
|
|
1976
|
+
seg.framing = framing;
|
|
1977
|
+
if (added.length > 0) {
|
|
1978
|
+
count += added.length;
|
|
1979
|
+
seg.note = withHow(seg.note, [`cuts added at ${added.map((t) => `${t.toFixed(2)}s`).join(", ")}`]);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
return `addedCuts: ${count} cut${count === 1 ? "" : "s"} added where ${everySec}s passed with no cut; ` +
|
|
1983
|
+
`the longest stretch left with no cut is ${longest.toFixed(1)}s`;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
/** A segment's own zoom: plain, the pace pass's step or the punch-in. */
|
|
1987
|
+
const ownZoomOf = (seg) => (seg.punchIn ? PUNCH_IN_SCALE : seg.paceZoom ? PACE_PASS.zoom : 1);
|
|
1988
|
+
|
|
1989
|
+
/** addedCuts: the zoom of a segment's other framing, against its own (plain, the pace pass's step or the punch-in). */
|
|
1990
|
+
export function alternateZoom(seg) {
|
|
1991
|
+
const own = ownZoomOf(seg);
|
|
1992
|
+
return own > ADDED_CUT.tightPast ? own / ADDED_CUT.zoom : own * ADDED_CUT.zoom;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
/**
|
|
1996
|
+
* addedCuts, once the spine's own framing is set (punch-ins, the pace pass's steps): a take the row reaches (`framing`
|
|
1997
|
+
* set) whose own zoom is within FRAMING_SAME_WITHIN of the zoom the take before it ends in starts in its other framing
|
|
1998
|
+
* (`otherFirst`), so the join between them still changes the picture. After a segment the row does not reach (a
|
|
1999
|
+
* reaction beat) the take keeps its own. Returns, by segment, whether it starts in its other framing.
|
|
2000
|
+
*/
|
|
2001
|
+
export function framingAtJoins(spine) {
|
|
2002
|
+
let last = null;
|
|
2003
|
+
return spine.map((seg) => {
|
|
2004
|
+
const own = ownZoomOf(seg);
|
|
2005
|
+
// A segment the row does not reach (a reaction beat): the join after it changes the picture already.
|
|
2006
|
+
if (!Array.isArray(seg.framing)) {
|
|
2007
|
+
last = null;
|
|
2008
|
+
return false;
|
|
2009
|
+
}
|
|
2010
|
+
const otherFirst = last !== null && Math.abs(last - own) / own < FRAMING_SAME_WITHIN;
|
|
2011
|
+
if (otherFirst) seg.otherFirst = true;
|
|
2012
|
+
last = (seg.framing.length + (otherFirst ? 1 : 0)) % 2 === 1 ? alternateZoom(seg) : own;
|
|
2013
|
+
return otherFirst;
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
/**
|
|
2018
|
+
* addedCuts: where the cut changed a take's framing inside it (an added cut, or a pause cut that counts), in seconds
|
|
2019
|
+
* on the delivered film's clock: after the speed step, on the frame of the sped-up film that first shows it. The worker
|
|
2020
|
+
* joins a freeze that such a change splits, so its last guard reads a held picture as it would with no cut added.
|
|
2021
|
+
* Left out: a change under a cutaway, or within 1/24 s of the edge the film shows it at, where two freezes that meet
|
|
2022
|
+
* are two pictures. That edge can land a frame from the cutaway's own clock (one placed at 2.467 s first shows at
|
|
2023
|
+
* 2.5 s), so a change within FRAMING_NEAR_CUTAWAY frames of its edges on that clock is left out.
|
|
2024
|
+
*/
|
|
2025
|
+
export function framingChangeTimes(spine, speed = 1, cutaways = []) {
|
|
2026
|
+
const onFilm = (sec) => Math.round((sec / speed) * FPS) / FPS;
|
|
2027
|
+
const near = FRAMING_NEAR_CUTAWAY / FPS + 1e-6;
|
|
2028
|
+
const covered = cutaways.filter((c) => c.seconds > 0).map((c) => [onFilm(c.startSec) - near, onFilm(c.startSec + c.seconds) + near]);
|
|
2029
|
+
return spine.flatMap((seg) => (seg.framing ?? []).map((f) => onFilm(seg.startSec + f / FPS)))
|
|
2030
|
+
.filter((t) => !covered.some(([from, to]) => t >= from && t <= to));
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* addedCuts: a segment's picture, `head` being its chain up to its own framing, split at `seg.framing` into pieces cut by
|
|
2035
|
+
* frame number, back to back, every other one in its other framing, and joined again with no sound: every frame is
|
|
2036
|
+
* kept, in order, and the segment's sound is not touched. Returns the graph's chains, the last one ending in [v<i>].
|
|
2037
|
+
*/
|
|
2038
|
+
function framedPicture(head, i, seg, own) {
|
|
2039
|
+
const zoom = alternateZoom(seg);
|
|
2040
|
+
const other = `scale=${even(WIDTH * zoom)}:${even(HEIGHT * zoom)},crop=${WIDTH}:${HEIGHT}:(iw-ow)/2:(ih-oh)*${ADDED_CUT.top},setsar=1`;
|
|
2041
|
+
// A take with no change of its own that starts in its other framing (framingAtJoins) plays in it whole.
|
|
2042
|
+
if (seg.framing.length === 0) return [`${head},${other}[v${i}]`];
|
|
2043
|
+
const first = seg.otherFirst ? 1 : 0;
|
|
2044
|
+
const edges = [0, ...seg.framing];
|
|
2045
|
+
const chains = [`${head},split=${edges.length}${edges.map((_, p) => `[fr${i}_${p}]`).join("")}`];
|
|
2046
|
+
edges.forEach((from, p) => {
|
|
2047
|
+
const to = edges[p + 1];
|
|
2048
|
+
const look = (p + first) % 2 === 0 ? own : [other];
|
|
2049
|
+
chains.push(
|
|
2050
|
+
`[fr${i}_${p}]trim=start_frame=${from}${to === undefined ? "" : `:end_frame=${to}`},setpts=PTS-STARTPTS` +
|
|
2051
|
+
`${look.length ? `,${look.join(",")}` : ""}[fz${i}_${p}]`,
|
|
2052
|
+
);
|
|
2053
|
+
});
|
|
2054
|
+
chains.push(`${edges.map((_, p) => `[fz${i}_${p}]`).join("")}concat=n=${edges.length}:v=1:a=0[v${i}]`);
|
|
2055
|
+
return chains;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
1673
2058
|
/** cutPace: two pieces of one take, back to back. */
|
|
1674
2059
|
const samePiece = (prev, seg) =>
|
|
1675
2060
|
Boolean(prev.piece && seg.piece && prev.file === seg.file && prev.piece.take === seg.piece.take);
|
|
@@ -3288,16 +3673,21 @@ function assembleTimeline({
|
|
|
3288
3673
|
}
|
|
3289
3674
|
const pace = finish?.cutPace === true;
|
|
3290
3675
|
const lineGap = pace ? { max: PACE_SPLIT_PAUSE_SEC, keep: PACE_GAP_MAX_SEC } : null;
|
|
3291
|
-
// jumpCut stays off a template launch's cut, whose selected clocks and windows hold their real time.
|
|
3292
|
-
|
|
3676
|
+
// jumpCut stays off a template launch's cut, whose selected clocks and windows hold their real time. pauseTrim
|
|
3677
|
+
// (COP-355, a run's saved sheet) is jumpCut with one of Luke's pause levels in place of its numbers.
|
|
3678
|
+
const trim = finish?.pauseTrim && !template ? PAUSE_TRIMS[finish.pauseTrim] : null;
|
|
3679
|
+
const jump = trim ?? (finish?.jumpCut && manifest?.templateMotion?.enabled !== true ? JUMP_CUT : null);
|
|
3293
3680
|
// keepPauses (COP-350, a run's saved sheet): no pause inside a talking clip is shortened, neither a long sentence gap
|
|
3294
3681
|
// nor jumpCut's (no gap limit, no jump, no split); a sound in a break that is no heard word is still cut (#2554). A
|
|
3295
3682
|
// template launch's own speech edit runs as before.
|
|
3296
3683
|
const keepPauses = finish?.keepPauses === true && !template;
|
|
3297
3684
|
if (keepPauses) notes.push("keepPauses: no pause inside a clip is shortened; a sound in one that is no heard word is still cut");
|
|
3685
|
+
else if (trim) notes.push(`pauseTrim ${finish.pauseTrim}: a pause over ${trim.maxGap}s inside a clip is cut to about ${trim.keepAfter + trim.keepBefore}s`);
|
|
3298
3686
|
tightenSentenceGaps(spine, reactionCues, scriptLines, readLevels, keepPauses ? null : lineGap, keepPauses ? null : jump,
|
|
3299
3687
|
template ? storyboard : null, template ? manifest.templateMotion.editingTreatment : null, notes,
|
|
3300
3688
|
keepPauses ? Infinity : SENTENCE_GAP_MAX_SEC);
|
|
3689
|
+
// pauseTrim: each join inside a take fades its sound (PAUSE_JOIN_FADE_SEC); a level cuts close to the words.
|
|
3690
|
+
if (trim && !keepPauses) for (const seg of spine) if (seg.cuts?.length) seg.joinFadeSec = PAUSE_JOIN_FADE_SEC;
|
|
3301
3691
|
trimJoins(spine, reactionCues, scriptLines, pace ? PACE_GAP_MAX_SEC : null, finish?.talkTrim === true);
|
|
3302
3692
|
if (pace) {
|
|
3303
3693
|
// The pieces of one take alternate between the plain frame and the
|
|
@@ -3327,6 +3717,16 @@ function assembleTimeline({
|
|
|
3327
3717
|
seg.fadeInSec = quietStart(levels && seg.inSec > 0
|
|
3328
3718
|
? { ...levels, db: levels.db.slice(Math.floor(seg.inSec / levels.windowSec)) } : levels, seg.seconds);
|
|
3329
3719
|
});
|
|
3720
|
+
// addedCuts (COP-355, a run's saved sheet): the framing changes where a take runs too long with no cut; no time and
|
|
3721
|
+
// no sound moves. A template's clock or a measured map keeps its framing.
|
|
3722
|
+
if (finish?.addedCuts) {
|
|
3723
|
+
// With no line marked whole (no board, no script text) nothing says where a cut may not go, so none is added.
|
|
3724
|
+
notes.push(template || measure
|
|
3725
|
+
? "addedCuts: a cut on a template's clock or a measured map keeps its framing, so no cut was added"
|
|
3726
|
+
: !finish.wholeLines?.length
|
|
3727
|
+
? "addedCuts: no line of the script is marked whole, so no cut was added"
|
|
3728
|
+
: placeAddedCuts(spine, scriptLines, ADDED_CUTS[finish.addedCuts], finish.wholeLines));
|
|
3729
|
+
}
|
|
3330
3730
|
// A copied shot no voice runs in lasts its shot's length, its clip trimmed or its last frame held.
|
|
3331
3731
|
const shotOf = (n) => plans.get(n)?.sourceShot ?? null;
|
|
3332
3732
|
const shotSec = (n) => {
|
|
@@ -3947,7 +4347,7 @@ function mappedPiece(seg, i, { addInput, filters, tails, level, resolve }) {
|
|
|
3947
4347
|
* the voice and everything under it are also written to. `pcmMix` keeps the
|
|
3948
4348
|
* render's sound uncompressed, for a mix the loudness pass then encodes once.
|
|
3949
4349
|
*/
|
|
3950
|
-
export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null, sound = null }) {
|
|
4350
|
+
export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null, sound = null, voiceOnly = false }) {
|
|
3951
4351
|
const level = finish && finish.levelSegments === false ? "anull" : LOUDNORM;
|
|
3952
4352
|
const inputs = [];
|
|
3953
4353
|
let count = 0;
|
|
@@ -3984,7 +4384,14 @@ export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null,
|
|
|
3984
4384
|
filters.push(`[${i}:a]${stereo},asplit=${pieces}${Array.from({ length: pieces }, (_, p) => `[ap${i}_${p}]`).join("")}`);
|
|
3985
4385
|
for (let p = 0; p < pieces; p++) {
|
|
3986
4386
|
const end = p < cuts.length ? `:end=${kept[2 * p + 1].toFixed(6)}` : "";
|
|
3987
|
-
|
|
4387
|
+
// pauseTrim (COP-355): a short fade in and out at each join inside the take; no length changes. A piece shorter
|
|
4388
|
+
// than two fades fades over half its length at each end, so neither fade starts before it nor runs past it.
|
|
4389
|
+
const fade = seg.joinFadeSec;
|
|
4390
|
+
const length = p < cuts.length ? Number(kept[2 * p + 1].toFixed(6)) - Number(kept[2 * p].toFixed(6)) : Infinity;
|
|
4391
|
+
const d = fade && length < 2 * fade ? (Math.max(0, length) / 2).toFixed(6) : fade;
|
|
4392
|
+
const fades = !fade ? "" : `${p > 0 ? `,afade=t=in:d=${d}` : ""}${p < cuts.length
|
|
4393
|
+
? `,afade=t=out:st=${Math.max(0, length - Number(d)).toFixed(6)}:d=${d}` : ""}`;
|
|
4394
|
+
filters.push(`[ap${i}_${p}]atrim=start=${kept[2 * p].toFixed(6)}${end},asetpts=PTS-STARTPTS${fades}[aq${i}_${p}]`);
|
|
3988
4395
|
}
|
|
3989
4396
|
filters.push(
|
|
3990
4397
|
`${Array.from({ length: pieces }, (_, p) => `[aq${i}_${p}]`).join("")}concat=n=${pieces}:v=0:a=1[ac${i}]`,
|
|
@@ -4001,9 +4408,16 @@ export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null,
|
|
|
4001
4408
|
}
|
|
4002
4409
|
}
|
|
4003
4410
|
if (seg.holdSec > 0.01) fit.push(`tpad=stop_mode=clone:stop_duration=${sec(seg.holdSec)}`);
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4411
|
+
// addedCuts (COP-355): a segment with framing changes is split by frame into pieces, every other one in its other framing.
|
|
4412
|
+
const own = [...(seg.punchIn ? [PUNCH_IN] : []), ...(seg.paceZoom ? [PACE_ZOOM] : [])];
|
|
4413
|
+
// voiceOnly (COP-353): the voice-alone pass draws no picture.
|
|
4414
|
+
if (!voiceOnly) {
|
|
4415
|
+
if (seg.framing?.length > 0 || (seg.framing && seg.otherFirst)) filters.push(...framedPicture(`${norm(`${i}:v`)}${fit.length ? `,${fit.join(",")}` : ""}`, i, seg, own));
|
|
4416
|
+
else {
|
|
4417
|
+
fit.push(...own);
|
|
4418
|
+
filters.push(`${norm(`${i}:v`)}${fit.length ? `,${fit.join(",")}` : ""}[v${i}]`);
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4007
4421
|
// A segment split around a reaction beat starts partway into its sound too.
|
|
4008
4422
|
const skipIn = inSec > 0.001 ? `atrim=start=${sec(inSec)},asetpts=PTS-STARTPTS,` : "";
|
|
4009
4423
|
const [fadeIn, fadeOut] = [seg.fadeInSec ?? EDGE_FADE_SEC, seg.fadeOutSec ?? EDGE_FADE_SEC];
|
|
@@ -4039,10 +4453,12 @@ export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null,
|
|
|
4039
4453
|
} else {
|
|
4040
4454
|
filters.push(`anullsrc=r=48000:cl=stereo,atrim=0:${sec(seg.seconds)}[a${i}]`);
|
|
4041
4455
|
}
|
|
4042
|
-
pairs.push(`[v${i}][a${i}]`);
|
|
4456
|
+
pairs.push(voiceOnly ? `[a${i}]` : `[v${i}][a${i}]`);
|
|
4043
4457
|
}
|
|
4044
4458
|
|
|
4045
|
-
filters.push(
|
|
4459
|
+
filters.push(voiceOnly
|
|
4460
|
+
? `${pairs.join("")}concat=n=${pairs.length}:v=0:a=1[voicecat]`
|
|
4461
|
+
: `${pairs.join("")}concat=n=${pairs.length}:v=1:a=1[vcat][voicecat]`);
|
|
4046
4462
|
// The sound is padded or cut to the picture's exact length, so every stream
|
|
4047
4463
|
// ends on its own. No -shortest: ffmpeg 8 held the whole ad's frames for it,
|
|
4048
4464
|
// and Debian's ffmpeg 5.1 (the worker's) never ended at all (#2988).
|
|
@@ -4072,6 +4488,14 @@ export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null,
|
|
|
4072
4488
|
} else {
|
|
4073
4489
|
filters.push(`[voicecat]apad,${toPicture}[voice]`);
|
|
4074
4490
|
}
|
|
4491
|
+
// voiceOnly (COP-353): the voice alone after the chain `finish.clean` names, as the render joins it, with no picture
|
|
4492
|
+
// and nothing under it (the silences the worker's guard reads; COP-354: the voice's level a room bed is set against);
|
|
4493
|
+
// a reaction's tail, which is not the spoken voice, left out.
|
|
4494
|
+
if (voiceOnly) {
|
|
4495
|
+
filters.push(...tails.map((label) => `${label}anullsink`));
|
|
4496
|
+
filters.push(`[voice]${finish?.clean?.voice ?? "anull"}[measured]`);
|
|
4497
|
+
return ["-y", "-hide_banner", "-loglevel", "error", ...inputs, "-filter_complex", filters.join(";"), "-map", "[measured]", "-c:a", "pcm_s16le", out];
|
|
4498
|
+
}
|
|
4075
4499
|
|
|
4076
4500
|
let videoLabel = "vcat";
|
|
4077
4501
|
timeline.cutaways.forEach((c, j) => {
|
|
@@ -4170,7 +4594,7 @@ export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null,
|
|
|
4170
4594
|
);
|
|
4171
4595
|
beds.push(`[set${j}]`);
|
|
4172
4596
|
});
|
|
4173
|
-
} else if (sound?.roomTone !== false && (!timeline.mapped || !timeline.wholeVoice) && !timeline.wholeVoice?.songOnly) {
|
|
4597
|
+
} else if (!finish?.room && sound?.roomTone !== false && (!timeline.mapped || !timeline.wholeVoice) && !timeline.wholeVoice?.songOnly) {
|
|
4174
4598
|
filters.push(timeline.mapped
|
|
4175
4599
|
? `${ROOM_TONE},atrim=end_sample=${Math.round(pictureSec * EDIT_SAMPLE_RATE)}[room]`
|
|
4176
4600
|
: `${ROOM_TONE}[room]`);
|
|
@@ -4228,6 +4652,16 @@ export function buildFfmpegArgs(timeline, { resolve, music, out, finish = null,
|
|
|
4228
4652
|
voice = "[voiced]";
|
|
4229
4653
|
under = [...ducked.map((_, j) => `[ud${j}]`), ...tails];
|
|
4230
4654
|
}
|
|
4655
|
+
// COP-354, roomSound: the cut's own bed under the whole film, after the voice's chain and the duck, and not ducked.
|
|
4656
|
+
if (finish?.room?.file) {
|
|
4657
|
+
const r = finish.room;
|
|
4658
|
+
const k = addInput("-i", r.file);
|
|
4659
|
+
filters.push(
|
|
4660
|
+
`[${k}:a]${stereo},atrim=0:${pictureSec.toFixed(6)},asetpts=PTS-STARTPTS,volume=${r.gainDb}dB,` +
|
|
4661
|
+
`afade=t=in:d=${ROOM_FADE_SEC},afade=t=out:st=${sec(pictureSec - ROOM_FADE_SEC)}:d=${ROOM_FADE_SEC}[roombed]`,
|
|
4662
|
+
);
|
|
4663
|
+
under = [...under, "[roombed]"];
|
|
4664
|
+
}
|
|
4231
4665
|
if (finish?.meters) {
|
|
4232
4666
|
// cutChecks: the voice, and everything under it mixed, each also written alone to be measured.
|
|
4233
4667
|
filters.push(`${voice}asplit=2[metered][vmeter]`);
|
|
@@ -4834,10 +5268,13 @@ export function editAss({ captions = [], cap = null, cards = [], hook = null, en
|
|
|
4834
5268
|
`Style: Cap,Helvetica,${capSize},&H00FFFFFF,&H00FFFFFF,&H00000000,&H90000000,-1,0,0,0,100,100,0,0,1,${thick ? 7 : 1.5},${thick ? 4 : 2},5,60,60,0,1`,
|
|
4835
5269
|
"Style: Card,Helvetica,60,&H00141414,&H00141414,&H00FFFFFF,&H50000000,-1,0,0,0,100,100,0,0,3,18,4,5,0,0,0,1",
|
|
4836
5270
|
`Style: End,Helvetica,${Math.round(H * 0.045)},&H00FFFFFF,&H00FFFFFF,&H20101010,&H00000000,-1,0,0,0,100,100,2,0,3,40,0,5,0,0,0,1`,
|
|
4837
|
-
...(endLayers ? endCardStyles(endLayers.colors, H) : []),
|
|
5271
|
+
...(endLayers ? endCardStyles(endLayers.colors, H) : []),
|
|
5272
|
+
...(cards.some((c) => c.label && c.headline) ? [headlineStyle(H)] : []), "",
|
|
4838
5273
|
"[Events]", "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
|
4839
5274
|
...captions.map((c, k) => `Dialogue: 1,${csTime(starts[k])},${end(c, k)},Cap,,0,0,0,,{\\pos(${W / 2},${y})${c.colour ? `\\c${c.colour}${thick ? "" : `\\bord${CAPTION_COLOUR_MIN_OUTLINE}`}` : ""}}${c.text}`),
|
|
4840
|
-
...cards.filter((c) => c.label).
|
|
5275
|
+
...cards.filter((c) => c.label).flatMap((c) => (c.headline
|
|
5276
|
+
? headlineDialogues(c, W, H, at)
|
|
5277
|
+
: [`Dialogue: 2,${at(c.in)},${at(c.out)},Card,,0,0,0,,{${box(c.box)}\\fs${Math.round(H * 0.036)}\\fad(60,0)}${assText(c.label)}`])),
|
|
4841
5278
|
...(hook?.text ? [`Dialogue: 3,${at(hook.in)},${at(hook.out)},Card,,0,0,0,,{${box(hook.box)}\\fs${Math.round(H * 0.026)}}${assText(hook.text)}`] : []),
|
|
4842
5279
|
...(endCard ? [`Dialogue: 4,${at(endCard.in)},${at(endCard.out)},End,,0,0,0,,{\\pos(${W / 2},${H / 2})\\fad(120,0)}${assText(endCard.text)}`] : []),
|
|
4843
5280
|
...(endLayers ? endCardDialogues(endLayers, W, H, at) : []),
|
|
@@ -4867,9 +5304,14 @@ export const END_CARD_SEC = 2;
|
|
|
4867
5304
|
* speaks is left out.
|
|
4868
5305
|
*/
|
|
4869
5306
|
export function storyboardCards(storyboard, timeline) {
|
|
5307
|
+
return cardsOnLines(storyboard, timeline).map(({ card }) => card);
|
|
5308
|
+
}
|
|
5309
|
+
|
|
5310
|
+
/** storyboardCards, each card with the end of the line it is cued to, on the cut's clock. */
|
|
5311
|
+
function cardsOnLines(storyboard, timeline) {
|
|
4870
5312
|
const counts = lineWordCounts(storyboard);
|
|
4871
5313
|
const ctaId = storyboard?.cta?.overlayId;
|
|
4872
|
-
const
|
|
5314
|
+
const placed = [];
|
|
4873
5315
|
for (const o of storyboard?.overlays ?? []) {
|
|
4874
5316
|
if (!hasText(o?.text) || !hasText(o?.cueLineId) || o.overlayId === ctaId || PICTURE_OVERLAY.test(o.type ?? "")) continue;
|
|
4875
5317
|
const seg = timeline.spine.find((s) => !s.reaction && s.lineIds.includes(o.cueLineId));
|
|
@@ -4877,12 +5319,105 @@ export function storyboardCards(storyboard, timeline) {
|
|
|
4877
5319
|
if (!cue) continue;
|
|
4878
5320
|
const at = roundMs(Math.max(0, cue.startSec - CARD_LEAD_SEC));
|
|
4879
5321
|
const lineEnd = seg.startSec + (cueEndInSegment(seg, counts, o.cueLineId) ?? seg.seconds);
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
5322
|
+
placed.push({
|
|
5323
|
+
card: {
|
|
5324
|
+
n: placed.length + 1, label: o.text.trim(), box: cardBox(o.placement),
|
|
5325
|
+
in: at, out: roundMs(Math.max(lineEnd, at + BROLL_MIN_HOLD_SEC)), on: `line ${o.cueLineId}`,
|
|
5326
|
+
},
|
|
5327
|
+
lineEnd,
|
|
4883
5328
|
});
|
|
4884
5329
|
}
|
|
4885
|
-
return
|
|
5330
|
+
return placed;
|
|
5331
|
+
}
|
|
5332
|
+
|
|
5333
|
+
/**
|
|
5334
|
+
* COP-356, cardPlace "top" (a run's sheet, through the worker): the card as a headline at the top for the opening, as
|
|
5335
|
+
* Luke's hook test clips carry one. Heavy dark words over a white rounded box, centred left to right with its middle an
|
|
5336
|
+
* eighth of the way down the frame, from the first frame to the end of the line the card is cued to, and held
|
|
5337
|
+
* HEADLINE_MIN_SEC to HEADLINE_MAX_SEC of the finished film. It keeps its place: captions set high give way to it and
|
|
5338
|
+
* sit low (the worker writes them so, video/lib/sheetFinish.ts sheetFinishOf), as Luke's kit moves its captions off a
|
|
5339
|
+
* banner's place. The numbers are ours.
|
|
5340
|
+
*/
|
|
5341
|
+
export const HEADLINE_MIN_SEC = 2.5;
|
|
5342
|
+
export const HEADLINE_MAX_SEC = 6;
|
|
5343
|
+
/** The band the headline is centred in at the top: its middle at an eighth of the frame's height. */
|
|
5344
|
+
export const HEADLINE_BOX = [0.08, 0.1, 0.92, 0.15];
|
|
5345
|
+
/** The white box around the words, in pixels of a 1920-high frame: its padding and its corners' radius. */
|
|
5346
|
+
const HEADLINE_PAD_PX = 18;
|
|
5347
|
+
const HEADLINE_RADIUS_PX = 21;
|
|
5348
|
+
const headlineFontPx = (H) => Math.round(H * 0.036);
|
|
5349
|
+
|
|
5350
|
+
/**
|
|
5351
|
+
* The words' width on the worker's font, which draws "Helvetica" Bold as DejaVu Sans Bold (its image holds only DejaVu):
|
|
5352
|
+
* DejaVu Sans Bold's advance widths in its units, printable ASCII from the space, then the quotes and dashes the card
|
|
5353
|
+
* takes. libass sizes a font so its ascent and descent (2384 units) are the font size. Any other character counts as the
|
|
5354
|
+
* widest letter, so the box is never narrower than the words there; a mark counts as nothing (a letter's accent).
|
|
5355
|
+
*/
|
|
5356
|
+
const HEADLINE_ADVANCE = [
|
|
5357
|
+
713, 934, 1067, 1716, 1425, 2052, 1786, 627, 936, 936, 1071, 1716, 778, 850, 778, 748, 1425, 1425, 1425, 1425, 1425, 1425,
|
|
5358
|
+
1425, 1425, 1425, 1425, 819, 819, 1716, 1716, 1716, 1188, 2048, 1585, 1561, 1503, 1700, 1399, 1399, 1681, 1714, 762, 762,
|
|
5359
|
+
1587, 1305, 2038, 1714, 1741, 1501, 1741, 1577, 1475, 1397, 1663, 1585, 2259, 1579, 1483, 1485, 936, 748, 936, 1716, 1024,
|
|
5360
|
+
1024, 1382, 1466, 1214, 1466, 1389, 891, 1466, 1458, 702, 702, 1362, 702, 2134, 1458, 1407, 1466, 1466, 1010, 1219, 979,
|
|
5361
|
+
1458, 1335, 1892, 1321, 1335, 1192, 1458, 748, 1458, 1716,
|
|
5362
|
+
];
|
|
5363
|
+
const HEADLINE_ADVANCE_MORE = { "\u2018": 778, "\u2019": 778, "\u201C": 1346, "\u201D": 1346, "\u2013": 1024, "\u2014": 2048 };
|
|
5364
|
+
const HEADLINE_FONT_UNITS = 2384;
|
|
5365
|
+
const HEADLINE_WIDEST = 2259;
|
|
5366
|
+
|
|
5367
|
+
/** The headline's words' width in pixels at `fontPx` (HEADLINE_ADVANCE). */
|
|
5368
|
+
export function headlineWordsPx(text, fontPx) {
|
|
5369
|
+
let units = 0;
|
|
5370
|
+
for (const char of String(text).normalize("NFD")) {
|
|
5371
|
+
if (/\p{M}/u.test(char)) continue;
|
|
5372
|
+
const code = char.codePointAt(0);
|
|
5373
|
+
units += (code >= 32 && code <= 126 ? HEADLINE_ADVANCE[code - 32] : HEADLINE_ADVANCE_MORE[char]) ?? HEADLINE_WIDEST;
|
|
5374
|
+
}
|
|
5375
|
+
return (units * fontPx) / HEADLINE_FONT_UNITS;
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
/**
|
|
5379
|
+
* The cards as storyboardCards places them, the first as the headline (cardPlace "top"): from the first frame to the end
|
|
5380
|
+
* of its line, HEADLINE_MIN_SEC to HEADLINE_MAX_SEC of the film at `speed`, in HEADLINE_BOX.
|
|
5381
|
+
*/
|
|
5382
|
+
export function headlineCards(storyboard, timeline, { speed = 1 } = {}) {
|
|
5383
|
+
return cardsOnLines(storyboard, timeline).map(({ card, lineEnd }, k) => (k > 0 ? card : {
|
|
5384
|
+
...card,
|
|
5385
|
+
box: HEADLINE_BOX,
|
|
5386
|
+
in: 0,
|
|
5387
|
+
out: roundMs(Math.min(Math.max(lineEnd, HEADLINE_MIN_SEC * speed), HEADLINE_MAX_SEC * speed)),
|
|
5388
|
+
headline: true,
|
|
5389
|
+
}));
|
|
5390
|
+
}
|
|
5391
|
+
|
|
5392
|
+
/** The headline's style: bold, near-black words with no edge or shadow, centred; its box is a drawing in the same style. */
|
|
5393
|
+
function headlineStyle(H) {
|
|
5394
|
+
return `Style: Head,Helvetica,${headlineFontPx(H)},&H00141414,&H00141414,&H00FFFFFF,&H00000000,-1,0,0,0,100,100,0,0,1,0,0,5,0,0,0,1`;
|
|
5395
|
+
}
|
|
5396
|
+
|
|
5397
|
+
/** A rounded box `w` by `h` as an ASS drawing from its top left corner, its corners quarter circles of radius `r`. */
|
|
5398
|
+
function roundedBoxPath(w, h, r) {
|
|
5399
|
+
const k = Math.round(r * 0.5523);
|
|
5400
|
+
return [
|
|
5401
|
+
`m ${r} 0`, `l ${w - r} 0`, `b ${w - r + k} 0 ${w} ${r - k} ${w} ${r}`,
|
|
5402
|
+
`l ${w} ${h - r}`, `b ${w} ${h - r + k} ${w - r + k} ${h} ${w - r} ${h}`,
|
|
5403
|
+
`l ${r} ${h}`, `b ${r - k} ${h} 0 ${h - r + k} 0 ${h - r}`,
|
|
5404
|
+
`l 0 ${r}`, `b 0 ${r - k} ${r - k} 0 ${r} 0`,
|
|
5405
|
+
].join(" ");
|
|
5406
|
+
}
|
|
5407
|
+
|
|
5408
|
+
/** The headline's two events: the white rounded box under, the words over, both on for the headline's time. */
|
|
5409
|
+
function headlineDialogues(c, W, H, at) {
|
|
5410
|
+
const fontPx = headlineFontPx(H);
|
|
5411
|
+
const cx = Math.round(((c.box[0] + c.box[2]) / 2) * W);
|
|
5412
|
+
const cy = Math.round(((c.box[1] + c.box[3]) / 2) * H);
|
|
5413
|
+
const w = Math.min(W, Math.ceil(headlineWordsPx(assText(c.label), fontPx)) + 2 * HEADLINE_PAD_PX);
|
|
5414
|
+
const h = fontPx + 2 * HEADLINE_PAD_PX;
|
|
5415
|
+
const x0 = Math.round(cx - w / 2);
|
|
5416
|
+
const y0 = Math.round(cy - h / 2);
|
|
5417
|
+
return [
|
|
5418
|
+
`Dialogue: 2,${at(c.in)},${at(c.out)},Head,,0,0,0,,{\\an7\\pos(${x0},${y0})\\1c&HFFFFFF&\\p1}${roundedBoxPath(w, h, HEADLINE_RADIUS_PX)}`,
|
|
5419
|
+
`Dialogue: 3,${at(c.in)},${at(c.out)},Head,,0,0,0,,{\\pos(${cx},${cy})}${assText(c.label)}`,
|
|
5420
|
+
];
|
|
4886
5421
|
}
|
|
4887
5422
|
|
|
4888
5423
|
/**
|
|
@@ -5310,12 +5845,13 @@ export function readMotion(stdout) {
|
|
|
5310
5845
|
const rows = [];
|
|
5311
5846
|
let t = null;
|
|
5312
5847
|
for (const line of String(stdout ?? "").split("\n")) {
|
|
5313
|
-
|
|
5848
|
+
// COP-361: ffmpeg prints a tiny number with %g ("6.94444e-05"); the exponent and a sign are part of the number.
|
|
5849
|
+
const time = line.match(/pts_time:([-+]?[\d.]+(?:e[-+]?\d+)?)/i);
|
|
5314
5850
|
if (time) {
|
|
5315
5851
|
t = Number(time[1]);
|
|
5316
5852
|
continue;
|
|
5317
5853
|
}
|
|
5318
|
-
const y = line.match(/YAVG=([\d.]+)/);
|
|
5854
|
+
const y = line.match(/YAVG=([-+]?[\d.]+(?:e[-+]?\d+)?)/i);
|
|
5319
5855
|
if (y && t !== null) rows.push({ t, y: Number(y[1]) });
|
|
5320
5856
|
}
|
|
5321
5857
|
return rows;
|
|
@@ -5766,7 +6302,18 @@ export function readLoudness(stderr) {
|
|
|
5766
6302
|
* worker's, stops the pass: "Cannot select channel layout for the link between
|
|
5767
6303
|
* filters". ffmpeg 8 makes the same sound either way.
|
|
5768
6304
|
*/
|
|
5769
|
-
export function loudnessApplyArgs(mix, measured, out, limiter = null) {
|
|
6305
|
+
export function loudnessApplyArgs(mix, measured, out, limiter = null, linear = false) {
|
|
6306
|
+
// COP-354: under a room bed, pass one's gain alone, the same for every sample, ahead of the limiter: loudnorm's dynamic
|
|
6307
|
+
// mode would lift the bed in a long pause. Only with the limiter: without it a plain gain can end over the peak bar
|
|
6308
|
+
// where loudnorm keeps the film under it, so that cut takes today's pass.
|
|
6309
|
+
if (linear && measured && limiter) {
|
|
6310
|
+
return [
|
|
6311
|
+
"-y", "-hide_banner", "-loglevel", "error", "-i", mix,
|
|
6312
|
+
"-map", "0:v:0", "-map", "0:a:0", "-c:v", "copy",
|
|
6313
|
+
"-af", `volume=${round2(FINISH_LUFS - measured.i)}dB${limiter ? `,${limiter}` : ""},${stereo}`,
|
|
6314
|
+
"-c:a", "aac", "-b:a", "192k", "-movflags", "+faststart", out,
|
|
6315
|
+
];
|
|
6316
|
+
}
|
|
5770
6317
|
const second = measured
|
|
5771
6318
|
? `:measured_I=${measured.i}:measured_TP=${measured.tp}:measured_LRA=${measured.lra}` +
|
|
5772
6319
|
`:measured_thresh=${measured.thresh}:offset=${measured.offset}:linear=true`
|
|
@@ -5810,8 +6357,8 @@ function ffmpegReason(res) {
|
|
|
5810
6357
|
}
|
|
5811
6358
|
|
|
5812
6359
|
/** The mix normalized with pass one's numbers into `out`, through the limiter at `limit` when one is given. */
|
|
5813
|
-
function applyLoudness(mix, measured, out, limit) {
|
|
5814
|
-
const args = loudnessApplyArgs(mix, measured, out, limit == null ? null : peakLimiter(limit));
|
|
6360
|
+
function applyLoudness(mix, measured, out, limit, linear = false) {
|
|
6361
|
+
const args = loudnessApplyArgs(mix, measured, out, limit == null ? null : peakLimiter(limit), linear);
|
|
5815
6362
|
const res = spawnSync("ffmpeg", args, { stdio: ["inherit", "inherit", "pipe"], encoding: "utf8", maxBuffer: 1 << 26 });
|
|
5816
6363
|
if (res.status !== 0) {
|
|
5817
6364
|
// ffmpeg's words still reach the log, and its reason leads the error:
|
|
@@ -5826,17 +6373,18 @@ function applyLoudness(mix, measured, out, limit) {
|
|
|
5826
6373
|
/** Both passes on the mix, then the finished cut measured again. A receipt may
|
|
5827
6374
|
* retain that final observation without changing the legacy mastering result.
|
|
5828
6375
|
* `limit` (limitPeaks) is the limiter's ceiling, PEAK_LIMIT; a limited cut over
|
|
5829
|
-
* the limit is limited again lower (LIMIT_AGAIN_MAX), one under it is left as it is.
|
|
5830
|
-
|
|
6376
|
+
* the limit is limited again lower (LIMIT_AGAIN_MAX), one under it is left as it is.
|
|
6377
|
+
* `linear` (COP-354, a room bed laid): pass two is pass one's gain alone (loudnessApplyArgs). */
|
|
6378
|
+
export function finishLoudnessPass(mix, out, limit = null, onMeasured = null, linear = false) {
|
|
5831
6379
|
const measured = measureLoudness(mix);
|
|
5832
6380
|
let ceiling = limit;
|
|
5833
|
-
let finished = applyLoudness(mix, measured, out, ceiling);
|
|
6381
|
+
let finished = applyLoudness(mix, measured, out, ceiling, linear);
|
|
5834
6382
|
let again = 0;
|
|
5835
6383
|
while (ceiling != null && finished && finished.tp > TRUE_PEAK_MAX_DB && again < LIMIT_AGAIN_MAX) {
|
|
5836
6384
|
const lower = lowerPeakLimit(ceiling, finished.tp);
|
|
5837
6385
|
if (lower >= ceiling) break;
|
|
5838
6386
|
ceiling = lower;
|
|
5839
|
-
finished = applyLoudness(mix, measured, out, ceiling);
|
|
6387
|
+
finished = applyLoudness(mix, measured, out, ceiling, linear);
|
|
5840
6388
|
again++;
|
|
5841
6389
|
}
|
|
5842
6390
|
const refusal = truePeakRefusal(finished);
|
|
@@ -5848,6 +6396,117 @@ export function finishLoudnessPass(mix, out, limit = null, onMeasured = null) {
|
|
|
5848
6396
|
};
|
|
5849
6397
|
}
|
|
5850
6398
|
|
|
6399
|
+
/**
|
|
6400
|
+
* COP-353: the worker's last guard (scout auto-cut.ts deadStretch) reads silences off the finished film with ffmpeg's
|
|
6401
|
+
* silencedetect at these numbers (media-probe.ts SILENCE_NOISE, SILENCE_MIN_DURATION_SEC). A picked voice chain lifts
|
|
6402
|
+
* the film's quiet floor over that noise level, so the cut reads them off the voice alone instead (heardSilences).
|
|
6403
|
+
*/
|
|
6404
|
+
export const GUARD_SILENCE = { noise: "-50dB", minSec: 0.5 };
|
|
6405
|
+
/** COP-353: said when other sounds lie under the voice, so the voice alone is not the film's silence. */
|
|
6406
|
+
const SOUNDS_UNDER_NOTE = "voiceSilences: music lies under the voice, so the worker's last guard reads the film's own silences, as today";
|
|
6407
|
+
/**
|
|
6408
|
+
* A sound effect, a bed of its own or a reaction's tail sounds under only part of the voice: the voice alone is not the
|
|
6409
|
+
* film's silence, and the film's own silences would be filled by a picked chain's floor or a room bed. So the pick is
|
|
6410
|
+
* not used there, and the worker's last guard reads the film as today.
|
|
6411
|
+
*/
|
|
6412
|
+
const partlyUnderNote = (what, kept) =>
|
|
6413
|
+
`${what}: a sound effect, a bed or a reaction's end lies under part of the voice, so the worker's last guard could not ` +
|
|
6414
|
+
`hear a silent stretch with it; ${kept}`;
|
|
6415
|
+
|
|
6416
|
+
/**
|
|
6417
|
+
* COP-353: the voice's silences as today's cut would deliver it: the voice alone through `clean` (today's chain, or
|
|
6418
|
+
* none), at the film's level (the loudness pass's gain, with finishLoudness), read as the worker reads a film's (paired
|
|
6419
|
+
* starts and ends; a start with no end left out, as there), on the finished film's clock (the voice is the mix's clock,
|
|
6420
|
+
* before the speed step); null when ffmpeg cannot make or read it.
|
|
6421
|
+
*/
|
|
6422
|
+
function heardSilences(timeline, { resolve, out, clean, levelSegments, finishLoudness, speed }) {
|
|
6423
|
+
const base = path.resolve(path.dirname(out), path.basename(out, path.extname(out)));
|
|
6424
|
+
const file = `${base}.voice-silence.wav`;
|
|
6425
|
+
try {
|
|
6426
|
+
const args = buildFfmpegArgs(timeline, { resolve, music: null, out: file, finish: { levelSegments, ...(clean ? { clean } : {}) }, voiceOnly: true });
|
|
6427
|
+
if (spawnSync("ffmpeg", args, { stdio: ["ignore", "ignore", "pipe"] }).status !== 0) return null;
|
|
6428
|
+
const lufs = finishLoudness ? measureLufs(file) : null;
|
|
6429
|
+
const gainDb = heardVoice(lufs) ? round2(FINISH_LUFS - lufs) : 0;
|
|
6430
|
+
// The shortest silence on the film's clock: the voice runs before the speed step, so it is that much longer here.
|
|
6431
|
+
const res = spawnSync("ffmpeg", ["-hide_banner", "-nostats", "-i", file, "-af",
|
|
6432
|
+
`volume=${gainDb}dB,silencedetect=n=${GUARD_SILENCE.noise}:d=${roundMs(GUARD_SILENCE.minSec * speed)}`, "-f", "null", "-"],
|
|
6433
|
+
{ encoding: "utf8", maxBuffer: 1 << 26 });
|
|
6434
|
+
if (res.status !== 0) return null;
|
|
6435
|
+
const runs = [];
|
|
6436
|
+
for (const line of String(res.stderr ?? "").split(/\r?\n/)) {
|
|
6437
|
+
// COP-361: ffmpeg prints a tiny number with %g ("6.25e-05"); the exponent and a sign are part of the number.
|
|
6438
|
+
const start = line.match(/silence_start\s*[:=]\s*([-+]?[\d.]+(?:e[-+]?\d+)?)/i);
|
|
6439
|
+
if (start) {
|
|
6440
|
+
runs.push({ start: Number(start[1]), duration: NaN });
|
|
6441
|
+
continue;
|
|
6442
|
+
}
|
|
6443
|
+
const end = line.match(/silence_end\s*[:=]\s*([-+]?[\d.]+(?:e[-+]?\d+)?).*?silence_duration\s*[:=]\s*([-+]?[\d.]+(?:e[-+]?\d+)?)/i);
|
|
6444
|
+
if (!end) continue;
|
|
6445
|
+
const last = runs.at(-1);
|
|
6446
|
+
if (last && !Number.isFinite(last.duration)) Object.assign(last, { end: Number(end[1]), duration: Number(end[2]) });
|
|
6447
|
+
else runs.push({ start: Number(end[1]) - Number(end[2]), end: Number(end[1]), duration: Number(end[2]) });
|
|
6448
|
+
}
|
|
6449
|
+
return runs.filter((r) => Number.isFinite(r.duration))
|
|
6450
|
+
.map((r) => ({ start: roundMs(r.start / speed), end: roundMs(r.end / speed), duration: roundMs(r.duration / speed) }));
|
|
6451
|
+
} finally {
|
|
6452
|
+
rmSync(file, { force: true });
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
|
|
6456
|
+
/** COP-354: the two working files of a room bed, beside the cut: the voice measured alone, and the bed. */
|
|
6457
|
+
function roomPaths(out) {
|
|
6458
|
+
const base = path.resolve(path.dirname(out), path.basename(out, path.extname(out)));
|
|
6459
|
+
return { voice: `${base}.voice-level.wav`, bed: `${base}.room.wav` };
|
|
6460
|
+
}
|
|
6461
|
+
|
|
6462
|
+
/** COP-354: a sound file's RMS level (dBFS), decoded as floats; null when ffmpeg cannot read it or it is silent. */
|
|
6463
|
+
function rmsDbOf(file) {
|
|
6464
|
+
const res = spawnSync("ffmpeg", ["-v", "error", "-i", file, "-map", "0:a:0", "-ac", "1", "-f", "f32le", "-"], { maxBuffer: 1 << 30 });
|
|
6465
|
+
if (res.status !== 0 || !res.stdout?.length) return null;
|
|
6466
|
+
const bytes = res.stdout.subarray(0, res.stdout.length & ~3);
|
|
6467
|
+
const x = new Float32Array(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.length));
|
|
6468
|
+
let power = 0;
|
|
6469
|
+
for (const v of x) power += v * v;
|
|
6470
|
+
return power > 0 ? round2(10 * Math.log10(power / x.length)) : null;
|
|
6471
|
+
}
|
|
6472
|
+
|
|
6473
|
+
/**
|
|
6474
|
+
* COP-354: a room bed for this cut: the voice measured alone after its chain (one pass of its sound, no picture), the
|
|
6475
|
+
* bed made by its preset for the film's whole length and measured, and the gain that puts its RMS ROOM_UNDER_DB under
|
|
6476
|
+
* the voice's integrated loudness (gainUnder). Or, when one cannot be had, the note that says why; the cut then keeps
|
|
6477
|
+
* its own faint bed.
|
|
6478
|
+
*/
|
|
6479
|
+
function roomBed(name, timeline, { resolve, out, clean, levelSegments, pictureSec }) {
|
|
6480
|
+
const files = roomPaths(out);
|
|
6481
|
+
const voiceArgs = buildFfmpegArgs(timeline, { resolve, music: null, out: files.voice, finish: { levelSegments, ...(clean ? { clean } : {}) }, voiceOnly: true });
|
|
6482
|
+
if (spawnSync("ffmpeg", voiceArgs, { stdio: ["ignore", "ignore", "pipe"] }).status !== 0) {
|
|
6483
|
+
rmSync(files.voice, { force: true });
|
|
6484
|
+
return { note: `roomSound ${name}: ffmpeg could not render the voice alone, so the cut's own faint room tone stayed` };
|
|
6485
|
+
}
|
|
6486
|
+
const voiceLufs = measureLufs(files.voice);
|
|
6487
|
+
rmSync(files.voice, { force: true });
|
|
6488
|
+
if (!heardVoice(voiceLufs)) {
|
|
6489
|
+
return { note: `roomSound ${name}: the voice had no loudness to set the room against, so the cut's own faint room tone stayed` };
|
|
6490
|
+
}
|
|
6491
|
+
const made = spawnSync("ffmpeg", roomBedArgs(name, pictureSec, files.bed), { stdio: ["ignore", "ignore", "pipe"] });
|
|
6492
|
+
const bedRmsDb = made.status === 0 ? rmsDbOf(files.bed) : null;
|
|
6493
|
+
const gainDb = gainUnder(voiceLufs, ROOM_UNDER_DB, bedRmsDb, null);
|
|
6494
|
+
if (gainDb === null) {
|
|
6495
|
+
rmSync(files.bed, { force: true });
|
|
6496
|
+
return { note: `roomSound ${name}: ffmpeg could not make the room, so the cut's own faint room tone stayed` };
|
|
6497
|
+
}
|
|
6498
|
+
return { room: { file: files.bed, gainDb }, record: { sound: name, voiceLufs, bedRmsDb, gainDb, underDb: ROOM_UNDER_DB } };
|
|
6499
|
+
}
|
|
6500
|
+
|
|
6501
|
+
/**
|
|
6502
|
+
* COP-354: whether the cut lays its own faint room tone (ROOM_TONE), the bed a room sound stands in for: not on a cut
|
|
6503
|
+
* laid on its measured map, a voice laid whole, a run with beds of its own (ElevenLabs), or one whose manifest turns
|
|
6504
|
+
* the room tone off.
|
|
6505
|
+
*/
|
|
6506
|
+
export function laysOwnRoomTone({ mapped, wholeVoice, fileBeds, roomTone }) {
|
|
6507
|
+
return !mapped && !wholeVoice && !fileBeds && roomTone !== false;
|
|
6508
|
+
}
|
|
6509
|
+
|
|
5851
6510
|
/** The filters of `names` this ffmpeg does not have. */
|
|
5852
6511
|
function missingFilters(names) {
|
|
5853
6512
|
const listed = spawnSync("ffmpeg", ["-hide_banner", "-filters"]).stdout?.toString() ?? "";
|
|
@@ -7006,10 +7665,14 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7006
7665
|
if (finish?.pacePass && !paced) notes.push("this cut keeps a real-time clock, so pacePass did not speed it up or zoom it");
|
|
7007
7666
|
const paceSpeed = finish?.paceSpeed ?? PACE_PASS.speed;
|
|
7008
7667
|
if (paced) notes.push(paceZooms(timeline.spine, paceSpeed));
|
|
7668
|
+
// addedCuts (COP-355): with each take's own framing now set, no join between two takes shows the same picture.
|
|
7669
|
+
framingAtJoins(timeline.spine);
|
|
7009
7670
|
const speed = paced
|
|
7010
7671
|
? paceSpeed
|
|
7011
7672
|
: finish?.cutPace && !template && !timeline.wholeVoice && !protectedMotion ? speedFor(pictureSec, finish.targetSeconds) : 1;
|
|
7012
7673
|
if (finish?.cutPace && (template || protectedMotion)) notes.push("template/action/listening/ending clocks remain real time; cutPace does not accelerate the cut");
|
|
7674
|
+
// addedCuts (COP-355): the framing changes made, on the delivered film's clock, for the worker's last guard.
|
|
7675
|
+
const framingChangesSec = finish?.addedCuts ? framingChangeTimes(timeline.spine, speed, timeline.cutaways) : null;
|
|
7013
7676
|
if (timeline.sourceMap) {
|
|
7014
7677
|
// The exact bytes every measured clock was read from, for whoever binds an approval to them.
|
|
7015
7678
|
timeline.sourceMap.sources = readClocks.files().filter(exists).map((file) => {
|
|
@@ -7098,7 +7761,13 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7098
7761
|
? lineCaptionScreens(timed(lineWords(timeline, storyboard)), cap)
|
|
7099
7762
|
: captionScreens(timed(wordRows(timeline)), cap), endLayers);
|
|
7100
7763
|
if (finish.captions) burned = screens;
|
|
7101
|
-
|
|
7764
|
+
// COP-356: a run's sheet may put its card at the top, as a headline for the opening.
|
|
7765
|
+
const headline = finish.cards && !copied && finish.cardPlace === "top";
|
|
7766
|
+
burnedCards = finish.cards
|
|
7767
|
+
? (copied ? copied.cards : headline ? headlineCards(storyboard, timeline, { speed }) : storyboardCards(storyboard, timeline))
|
|
7768
|
+
: [];
|
|
7769
|
+
const drawn = burnedCards.find((c) => c.headline && c.label);
|
|
7770
|
+
if (drawn) notes.push(`cardPlace: the card is a headline at the top, from the first frame to ${roundMs(drawn.out / speed)} s`);
|
|
7102
7771
|
writeFileSync(here(ass), editAss({
|
|
7103
7772
|
captions: finish.captionColours ? colourScreens(screens, storyboard) : screens,
|
|
7104
7773
|
cap,
|
|
@@ -7118,13 +7787,28 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7118
7787
|
);
|
|
7119
7788
|
}
|
|
7120
7789
|
}
|
|
7121
|
-
// cleanVoice, where this ffmpeg has the filters. A voice laid whole is a song, kept as it is.
|
|
7790
|
+
// cleanVoice, where this ffmpeg has the filters. A voice laid whole is a song, kept as it is. COP-353: voiceSound
|
|
7791
|
+
// names another of the cut's chains in VOICE_CLEAN's place; where this ffmpeg lacks one of its filters, the voice is
|
|
7792
|
+
// cleaned as before, and the record says why.
|
|
7122
7793
|
let clean = null;
|
|
7794
|
+
// The chain today's cut would clean the voice with (none where it would not), for the silences the guard reads.
|
|
7795
|
+
let todayClean = null;
|
|
7123
7796
|
if (finish?.cleanVoice && !timeline.mapped) {
|
|
7124
|
-
const
|
|
7797
|
+
const picked = finish.voiceSound ? VOICE_SOUNDS[finish.voiceSound] : null;
|
|
7798
|
+
const needs = picked ? [...new Set([...chainFilters(picked), ...UNDER_FILTERS])] : [];
|
|
7799
|
+
const missing = timeline.wholeVoice ? [] : missingFilters(picked ? [...new Set([...CLEAN_FILTERS, ...needs])] : CLEAN_FILTERS);
|
|
7800
|
+
const own = CLEAN_FILTERS.filter((name) => missing.includes(name));
|
|
7801
|
+
const pickedMissing = needs.filter((name) => missing.includes(name));
|
|
7802
|
+
if (!timeline.wholeVoice && own.length === 0) todayClean = { voice: VOICE_CLEAN, under: UNDER_VOICE };
|
|
7125
7803
|
if (timeline.wholeVoice) notes.push("the voice is a song laid whole, so it was kept as it is, not cleaned");
|
|
7126
|
-
else if (
|
|
7127
|
-
else
|
|
7804
|
+
else if (picked && pickedMissing.length === 0) clean = { voice: picked, under: UNDER_VOICE };
|
|
7805
|
+
else if (own.length > 0) notes.push(`this ffmpeg has no ${own.join(", ")} filter, so the voice was not cleaned`);
|
|
7806
|
+
else {
|
|
7807
|
+
if (picked) {
|
|
7808
|
+
notes.push(`this ffmpeg has no ${pickedMissing.join(", ")} filter, so the voice was cleaned as before, not with voiceSound ${finish.voiceSound}`);
|
|
7809
|
+
}
|
|
7810
|
+
clean = { voice: VOICE_CLEAN, under: UNDER_VOICE };
|
|
7811
|
+
}
|
|
7128
7812
|
}
|
|
7129
7813
|
let peakLimit = null;
|
|
7130
7814
|
if (finish?.limitPeaks) {
|
|
@@ -7135,7 +7819,7 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7135
7819
|
const rendered = finish?.finishLoudness ? paths.mix : out;
|
|
7136
7820
|
const meters = finish?.cutChecks ? {
|
|
7137
7821
|
voice: paths.voice, bed: paths.bed,
|
|
7138
|
-
...(manifest.templateMotion?.enabled === true || manifest.roomTone === false ? { allowAbsentBed: true } : {}),
|
|
7822
|
+
...(manifest.templateMotion?.enabled === true || manifest.roomTone === false || finish.roomSound === "none" ? { allowAbsentBed: true } : {}),
|
|
7139
7823
|
} : null;
|
|
7140
7824
|
// The burn reads its file from the folder ffmpeg runs in, so every path is absolute then.
|
|
7141
7825
|
const at = ass ? (file) => path.resolve(dir, file) : here;
|
|
@@ -7215,6 +7899,65 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7215
7899
|
timeline.musicSource = { file: music, ...decoded, loop: true };
|
|
7216
7900
|
}
|
|
7217
7901
|
}
|
|
7902
|
+
// COP-353: a picked chain lifts the film's quiet floor over the worker's silence probe (-50 dB), which would then
|
|
7903
|
+
// hear no held, voiceless stretch. So the voice is heard alone, as today's cut would deliver it (its own chain, at the
|
|
7904
|
+
// film's level, no bed), and its silences go to the worker in the record (`voiceSilences`). If they cannot be read,
|
|
7905
|
+
// the pick is not used and the voice is cleaned as before. The voice alone is the film's silence only when nothing
|
|
7906
|
+
// else lies under it. Music runs under the whole film and fills its silences today already, so the worker reads the
|
|
7907
|
+
// film's own silences, as today, and the record says so. A sound effect, a bed of its own or a reaction's tail lies
|
|
7908
|
+
// under only part of it: the film's other silences would be hidden from the guard, so the pick is not used.
|
|
7909
|
+
const musicUnder = Boolean(music);
|
|
7910
|
+
const partlyUnder = !musicUnder && ((mixSound?.effects?.length ?? 0) > 0 || (mixSound?.beds?.length ?? 0) > 0 ||
|
|
7911
|
+
timeline.spine.some((seg) => seg.audio === "clip" && seg.reaction?.tail));
|
|
7912
|
+
let voiceSilencesHeard = null;
|
|
7913
|
+
if (clean && finish.voiceSound && clean.voice === VOICE_SOUNDS[finish.voiceSound]) {
|
|
7914
|
+
if (musicUnder) {
|
|
7915
|
+
notes.push(SOUNDS_UNDER_NOTE);
|
|
7916
|
+
} else if (partlyUnder) {
|
|
7917
|
+
notes.push(partlyUnderNote(`voiceSound ${finish.voiceSound}`, "the voice was cleaned as before"));
|
|
7918
|
+
clean = todayClean;
|
|
7919
|
+
} else {
|
|
7920
|
+
voiceSilencesHeard = heardSilences(timeline, {
|
|
7921
|
+
resolve: here, out, clean: todayClean, levelSegments: !finish.finishLoudness, finishLoudness: finish.finishLoudness, speed,
|
|
7922
|
+
});
|
|
7923
|
+
if (!voiceSilencesHeard) {
|
|
7924
|
+
notes.push(`voiceSound ${finish.voiceSound}: the voice's silences could not be read, so the voice was cleaned as before`);
|
|
7925
|
+
clean = todayClean;
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
// COP-354, roomSound: the cut's own bed in the place of its faint brown one, where it lays that one; none lays none.
|
|
7930
|
+
let room = null;
|
|
7931
|
+
let roomRecord = null;
|
|
7932
|
+
if (finish?.roomSound) {
|
|
7933
|
+
const laysOwn = laysOwnRoomTone({ mapped: timeline.mapped === true, wholeVoice: Boolean(timeline.wholeVoice), fileBeds: mixSound?.beds?.length ?? 0, roomTone: mixSound?.roomTone });
|
|
7934
|
+
if (!laysOwn) notes.push(`roomSound ${finish.roomSound} was not applied: this cut lays no room tone of its own`);
|
|
7935
|
+
else if (finish.roomSound === "none") {
|
|
7936
|
+
room = { none: true };
|
|
7937
|
+
roomRecord = { sound: "none" };
|
|
7938
|
+
} else {
|
|
7939
|
+
// A bed fills every silence of the film: the worker's guard reads the voice's own (COP-353's pass, once a cut),
|
|
7940
|
+
// unless music lies under the voice too, which fills the film's silences today already. A sound under only part
|
|
7941
|
+
// of it (partlyUnder) keeps the cut's own faint bed.
|
|
7942
|
+
if (!musicUnder && !partlyUnder) {
|
|
7943
|
+
voiceSilencesHeard ??= heardSilences(timeline, {
|
|
7944
|
+
resolve: here, out, clean: todayClean, levelSegments: !finish.finishLoudness, finishLoudness: finish.finishLoudness, speed,
|
|
7945
|
+
});
|
|
7946
|
+
}
|
|
7947
|
+
const made = partlyUnder
|
|
7948
|
+
? { note: partlyUnderNote(`roomSound ${finish.roomSound}`, "the cut's own faint room tone stayed") }
|
|
7949
|
+
: musicUnder || voiceSilencesHeard
|
|
7950
|
+
? roomBed(finish.roomSound, timeline, { resolve: at, out, clean, levelSegments: !finish.finishLoudness, pictureSec })
|
|
7951
|
+
: { note: `roomSound ${finish.roomSound}: the voice's silences could not be read, so the cut's own faint room tone stayed` };
|
|
7952
|
+
if (made.note) notes.push(made.note);
|
|
7953
|
+
else {
|
|
7954
|
+
({ room, record: roomRecord } = made);
|
|
7955
|
+
if (musicUnder && !notes.includes(SOUNDS_UNDER_NOTE)) notes.push(SOUNDS_UNDER_NOTE);
|
|
7956
|
+
}
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
// With neither a picked chain nor a bed in the film after all, the film is today's: the worker reads its own silences.
|
|
7960
|
+
if (!room?.file && !(clean && finish?.voiceSound && clean.voice === VOICE_SOUNDS[finish.voiceSound])) voiceSilencesHeard = null;
|
|
7218
7961
|
const ffmpegArgs = buildFfmpegArgs(timeline, {
|
|
7219
7962
|
resolve: at,
|
|
7220
7963
|
music: music ? at(music) : null,
|
|
@@ -7223,6 +7966,7 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7223
7966
|
? {
|
|
7224
7967
|
finish: {
|
|
7225
7968
|
levelSegments: !finish.finishLoudness, ass, speed, ...(finish.finishLoudness ? { pcmMix: true } : {}),
|
|
7969
|
+
...(room ? { room } : {}),
|
|
7226
7970
|
...(pictures.length ? { pictures } : {}), ...(clean ? { clean } : {}), ...(meters ? { meters } : {}),
|
|
7227
7971
|
...(endLayers ? { endCard: endLayers } : {}),
|
|
7228
7972
|
},
|
|
@@ -7235,6 +7979,7 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7235
7979
|
rmSync(meters.bed, { force: true });
|
|
7236
7980
|
}
|
|
7237
7981
|
const res = spawnSync("ffmpeg", ffmpegArgs, { stdio: "inherit", ...(ass ? { cwd: path.resolve(dir) } : {}) });
|
|
7982
|
+
if (room?.file) rmSync(room.file, { force: true });
|
|
7238
7983
|
if (res.status !== 0) {
|
|
7239
7984
|
const quoted = ffmpegArgs.map((a) => (/[\s\[\];]/.test(a) ? `'${a}'` : a)).join(" ");
|
|
7240
7985
|
throw new FirstCutError(1, `ffmpeg failed. The command it ran:\n ffmpeg ${quoted}`);
|
|
@@ -7250,7 +7995,7 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7250
7995
|
if (finish?.finishLoudness) {
|
|
7251
7996
|
try {
|
|
7252
7997
|
loudness = finishLoudnessPass(rendered, out, peakLimit, template
|
|
7253
|
-
? (measured) => { loudnessMeasurement = measured; } : null);
|
|
7998
|
+
? (measured) => { loudnessMeasurement = measured; } : null, Boolean(room?.file));
|
|
7254
7999
|
} catch (error) {
|
|
7255
8000
|
// A limited pass already limited itself again (#4573); the same mix would only be refused the same way.
|
|
7256
8001
|
if (!template || peakLimit != null || !(error instanceof FirstCutError)) throw error;
|
|
@@ -7404,10 +8149,17 @@ export function firstCut({ dir, out: outOpt, skip = new Set(), music: musicOn =
|
|
|
7404
8149
|
// COP-300: the caption file is timed on the finished, sped-up cut's clock, as it is burned after the speed step.
|
|
7405
8150
|
...(ass && speed !== 1 ? { captionClock: "final" } : {}),
|
|
7406
8151
|
...(sync ? { sync: syncRecord(sync) } : {}),
|
|
8152
|
+
// COP-353: the voice's silences as today's cut delivers it, which the worker's last guard reads in place of the film's.
|
|
8153
|
+
...(voiceSilencesHeard ? { voiceSilences: voiceSilencesHeard } : {}),
|
|
8154
|
+
// COP-354: the room sound the cut laid, and its level against the voice.
|
|
8155
|
+
...(roomRecord ? { room: roomRecord } : {}),
|
|
7407
8156
|
...(notes.length > 0 ? { notes } : {}),
|
|
7408
8157
|
};
|
|
7409
8158
|
writeFileSync(paths.pace, `${JSON.stringify(pace, null, 2)}\n`);
|
|
7410
|
-
return withSound({
|
|
8159
|
+
return withSound({
|
|
8160
|
+
out, durationSec, manifest, timeline, music, rows, sidecars, pace, ...(sync ? { sync } : {}),
|
|
8161
|
+
...(framingChangesSec ? { framingChangesSec } : {}),
|
|
8162
|
+
});
|
|
7411
8163
|
}
|
|
7412
8164
|
|
|
7413
8165
|
/**
|
|
@@ -7490,7 +8242,10 @@ function main() {
|
|
|
7490
8242
|
console.log("Sound at the edges (listen before uploading; the cut is unchanged):");
|
|
7491
8243
|
for (const line of edges) console.log(" " + line);
|
|
7492
8244
|
}
|
|
7493
|
-
|
|
8245
|
+
// COP-354: a room sound of the run's saved sheet is named, with its level; with none, there is none.
|
|
8246
|
+
const room = cut.pace?.room;
|
|
8247
|
+
const roomWords = room ? (room.sound === "none" ? "none" : `${room.sound}, ${ROOM_UNDER_DB} dB under the voice`) : null;
|
|
8248
|
+
console.log(`Room tone: ${roomWords ?? (manifest.roomTone === false ? "off" : "under the whole ad")}. Music bed: ${music ?? "none"}`);
|
|
7494
8249
|
if (cut.pace) {
|
|
7495
8250
|
const { pace } = cut;
|
|
7496
8251
|
const loud = pace.loudness ? `, ${pace.loudness.lufs} LUFS, true peak ${pace.loudness.truePeak} dBTP` : "";
|