@softure-ai/marketing-kit 0.13.1 → 0.14.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/CHANGELOG.md +45 -0
- package/README.md +27 -8
- package/dist/config/schema.d.ts +2 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +10 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/footage/compose.d.ts +13 -0
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +26 -14
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/film-mix.d.ts +27 -0
- package/dist/footage/film-mix.d.ts.map +1 -0
- package/dist/footage/film-mix.js +36 -0
- package/dist/footage/film-mix.js.map +1 -0
- package/dist/footage/loudness.d.ts +91 -27
- package/dist/footage/loudness.d.ts.map +1 -1
- package/dist/footage/loudness.js +143 -69
- package/dist/footage/loudness.js.map +1 -1
- package/dist/footage/pipeline.d.ts +38 -10
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +119 -63
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/publish.js +4 -4
- package/dist/footage/publish.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/og/element.d.ts.map +1 -1
- package/dist/og/element.js +8 -2
- package/dist/og/element.js.map +1 -1
- package/package.json +2 -2
- package/schema/marketing.schema.json +13 -1
- package/src/config/schema.ts +14 -2
- package/src/footage/compose.ts +33 -12
- package/src/footage/film-mix.ts +57 -0
- package/src/footage/loudness.ts +166 -68
- package/src/footage/pipeline.ts +151 -72
- package/src/footage/publish.ts +4 -4
- package/src/index.ts +28 -7
- package/src/og/element.ts +9 -2
|
@@ -9,7 +9,7 @@ import { type Edl } from "./edl.js";
|
|
|
9
9
|
import { type CutMeasure } from "./cuts.js";
|
|
10
10
|
import { type DeclickReport } from "./declick.js";
|
|
11
11
|
import { type FootageClip, type FootageFilm } from "./film.js";
|
|
12
|
-
import { type MixLoudness } from "./loudness.js";
|
|
12
|
+
import { type MixLoudness, type MixLoudnessTarget } from "./loudness.js";
|
|
13
13
|
import { type Frame, type NormalizeEncoder } from "./normalize.js";
|
|
14
14
|
import { type FootageProbe } from "./probe.js";
|
|
15
15
|
import { type CacheEntry } from "./paid.js";
|
|
@@ -226,34 +226,62 @@ export interface FinishedFootage {
|
|
|
226
226
|
/** The cover JPG, or null when the film has none. */
|
|
227
227
|
cover: string | null;
|
|
228
228
|
/** The finished file's sound as measured (EBU R128, true peak oversampled); null for a film without sound or a silent mix. */
|
|
229
|
-
loudness:
|
|
229
|
+
loudness: FinishedLoudness | null;
|
|
230
230
|
/**
|
|
231
|
-
* What the mix's last stage did: the
|
|
231
|
+
* What the mix's last stage did: the film's mix as measured, the gain applied (0 when `keep: "speech"` found the
|
|
232
232
|
* mix inside its window) and the limiter's ceiling; null when no stage ran (no sound, a silent mix, `mixLoudness: null`).
|
|
233
233
|
*/
|
|
234
234
|
mix: FinishedMix | null;
|
|
235
235
|
}
|
|
236
|
+
/** The finished file's sound in `FinishedFootage`. */
|
|
237
|
+
export interface FinishedLoudness extends MixLoudness {
|
|
238
|
+
/**
|
|
239
|
+
* A sentence naming both values when the mix landed in `mixLoudness.warnTolerance`'s near-miss band instead of
|
|
240
|
+
* inside its tolerance; null otherwise.
|
|
241
|
+
*/
|
|
242
|
+
warning: string | null;
|
|
243
|
+
}
|
|
236
244
|
/** The mix's last stage in `FinishedFootage`. */
|
|
237
245
|
export interface FinishedMix {
|
|
238
|
-
/** The
|
|
246
|
+
/** The film's mix before the stage. */
|
|
239
247
|
measured: MixLoudness;
|
|
240
248
|
gainDb: number;
|
|
241
249
|
ceilingDbtp: number;
|
|
242
250
|
/** What the gain kept (`MixLoudnessTarget.keep`). */
|
|
243
251
|
keep: "loudness" | "speech";
|
|
252
|
+
/** How many encodes the stage took. */
|
|
253
|
+
encodes: number;
|
|
244
254
|
}
|
|
255
|
+
/** A film's mix brought to its target by `mixFootage`: the encoded sound the final pass muxes, and what the stage did. */
|
|
256
|
+
export interface PreparedMix {
|
|
257
|
+
audioFile: string;
|
|
258
|
+
mix: FinishedMix;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The mix stage over a film's sound (`mixSource`, any file ffmpeg reads): measured, brought to `target` and encoded
|
|
262
|
+
* to `output` (AAC) by `finishMix`; null when the mix is silent (the final pass then keeps the render's sound). An
|
|
263
|
+
* error names the last measurement. `renderFootage` runs it before hyperframes renders a frame (issue #1124).
|
|
264
|
+
*/
|
|
265
|
+
export declare function mixFootage(target: MixLoudnessTarget, input: {
|
|
266
|
+
mixSource: string;
|
|
267
|
+
output: string;
|
|
268
|
+
}, options: {
|
|
269
|
+
log: (line: string) => void;
|
|
270
|
+
signal?: AbortSignal;
|
|
271
|
+
}): Promise<FootageResult<PreparedMix | null>>;
|
|
245
272
|
/**
|
|
246
|
-
* The final pass over hyperframes' render: the mix
|
|
247
|
-
*
|
|
248
|
-
* the
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* for tests only.
|
|
273
|
+
* The final pass over hyperframes' render: the film's mix (`input.mix`, prepared by `mixFootage` before the render;
|
|
274
|
+
* null keeps the render's sound; absent, the render's own sound goes through `mixFootage` here) muxed with the
|
|
275
|
+
* picture (copied where the render already matches; `finishVideo` re-encodes it to H.264 High at its preset and CRF),
|
|
276
|
+
* publishable codecs and fast start, checked with ffprobe, the finished file's sound measured and held to the target
|
|
277
|
+
* (a near miss inside `warnTolerance` finishes with `loudness.warning`), then the cover and the file's facts.
|
|
278
|
+
* Exported for tests only.
|
|
252
279
|
*/
|
|
253
280
|
export declare function finishFootage(film: Pick<FootageFilm, "mixLoudness" | "cover">, input: {
|
|
254
281
|
renderFile: string;
|
|
255
282
|
seconds: number;
|
|
256
283
|
coverAt: number;
|
|
284
|
+
mix?: PreparedMix | null;
|
|
257
285
|
}, options: Pick<RenderFootageOptions, "log" | "signal" | "output" | "onProgress" | "finishVideo">): Promise<FootageResult<FinishedFootage>>;
|
|
258
286
|
/** hyperframes' progress lines carry a percentage (`… 42%`); the last one on a line counts. */
|
|
259
287
|
export declare function readRenderPercent(line: string): number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/footage/pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAuD,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,EAA8D,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAEhG,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAA2D,KAAK,WAAW,EAAE,KAAK,WAAW,EAAoB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/footage/pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAW,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C;IAClB,gHAAgH;IAChH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAE/H"}
|
package/dist/footage/pipeline.js
CHANGED
|
@@ -7,7 +7,7 @@ import { copyFonts } from "../render/render.js";
|
|
|
7
7
|
import { err, ok } from "../voice/provider.js";
|
|
8
8
|
import { checkMusicFileType, describeAudioProbe, probeAudio } from "./audio.js";
|
|
9
9
|
import { readCachedTranscript, writeCacheFile, writeTranscript } from "./cache.js";
|
|
10
|
-
import { composeFootage, END_CARD_SECONDS, getFootageFilmSeconds } from "./compose.js";
|
|
10
|
+
import { composeFootage, END_CARD_SECONDS, getFootageFilmSeconds, getFootageSfxCues } from "./compose.js";
|
|
11
11
|
import { findMissingCaptionGlyphs, getCaptionBounds, getFootageCaptionLayout } from "./captions.js";
|
|
12
12
|
import { findLowDiskProblems, getFreeBytes, getRenderTempDir } from "./disk.js";
|
|
13
13
|
import { buildEdl, getEdlDuration, readEdl, remapWords, validateEdl } from "./edl.js";
|
|
@@ -16,7 +16,8 @@ import { chooseCutTransitions } from "./cuts.js";
|
|
|
16
16
|
import { declickSpeech, describeDeclick } from "./declick.js";
|
|
17
17
|
import { DEFAULT_AUTO_THRESHOLD, getDeclickLevel, getFootageEdit } from "./film.js";
|
|
18
18
|
import { getFilmKeyTerms } from "./keyterms.js";
|
|
19
|
-
import {
|
|
19
|
+
import { buildFilmMixArgs } from "./film-mix.js";
|
|
20
|
+
import { buildMixArgs, DEFAULT_LOUDNESS, formatDb, getFirstMixCeiling, getLoudnessVerdict, getMixAttempts, getMixFilter, getMixGain, getMixTolerance, getNextMixCeiling, measureLoudness, normalizeLoudness, solveMixGain, } from "./loudness.js";
|
|
20
21
|
import { duckingKeyframes, getDuckingOptions } from "./music.js";
|
|
21
22
|
import { FOOTAGE_FPS, normalizeFootage } from "./normalize.js";
|
|
22
23
|
import { buildPictureConcatArgs, buildPictureList, buildPicturePieceArgs, getPictureFrames, planFootagePicture } from "./picture.js";
|
|
@@ -551,6 +552,31 @@ async function runRenderFootage(film, clips, transcript, edl, options) {
|
|
|
551
552
|
const output = join(assetsDir, "music.mp3");
|
|
552
553
|
tracks.push({ item: "music", seconds, run: ffmpegTrack("The music track", output, () => buildMusicArgs({ input: musicFile, seconds, keyframes, output })) });
|
|
553
554
|
}
|
|
555
|
+
const sfx = {};
|
|
556
|
+
mkdirSync(join(assetsDir, "sfx"), { recursive: true });
|
|
557
|
+
for (const [event, source] of Object.entries(options.sfx)) {
|
|
558
|
+
const name = `${event}${extname(source)}`;
|
|
559
|
+
cpSync(source, join(assetsDir, "sfx", name));
|
|
560
|
+
sfx[event] = `assets/sfx/${name}`;
|
|
561
|
+
}
|
|
562
|
+
// The film's mix, brought to `mixLoudness` and gated before hyperframes captures a frame (issue #1124).
|
|
563
|
+
const mixLoudness = getMixLoudnessTarget(film);
|
|
564
|
+
let mixed = ok(null);
|
|
565
|
+
if (mixLoudness !== null) {
|
|
566
|
+
const mixSource = join(buildDir, "mix.wav");
|
|
567
|
+
const musicTrack = musicFile === null ? null : { file: join(assetsDir, "music.mp3"), seconds };
|
|
568
|
+
const cues = getFootageSfxCues(film, edl, sfx).map((cue) => ({ ...cue, src: join(buildDir, cue.src) }));
|
|
569
|
+
tracks.push({
|
|
570
|
+
item: "mix",
|
|
571
|
+
seconds,
|
|
572
|
+
run: async (onSeconds) => {
|
|
573
|
+
const args = buildFilmMixArgs({ speech: { file: speechFile, seconds: getEdlDuration(edl) }, music: musicTrack, sfx: cues, seconds, output: mixSource });
|
|
574
|
+
await runFfmpeg("The film's mix", args, { ...aborting, output: mixSource, onSeconds });
|
|
575
|
+
mixed = await mixFootage(mixLoudness, { mixSource, output: join(buildDir, "mix.m4a") }, { log, ...aborting });
|
|
576
|
+
rmSync(mixSource, { force: true });
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
}
|
|
554
580
|
// A single frame: counted as a moment of work so the stage's bar still ends at its total.
|
|
555
581
|
const lastFrame = join(assetsDir, "last.jpg");
|
|
556
582
|
tracks.push({ item: "last frame", seconds: 0.1, run: ffmpegTrack("The end card's backdrop", lastFrame, () => buildLastFrameArgs(edl, clipFiles, lastFrame)) });
|
|
@@ -568,17 +594,14 @@ async function runRenderFootage(film, clips, transcript, edl, options) {
|
|
|
568
594
|
await track.run((done) => assetProgress(index, done));
|
|
569
595
|
assetProgress(index, track.seconds);
|
|
570
596
|
}
|
|
597
|
+
// A mix that misses its target fails here, before any frame is rendered.
|
|
598
|
+
const prepared = mixed;
|
|
599
|
+
if (!prepared.ok)
|
|
600
|
+
return prepared;
|
|
571
601
|
const musicAsset = musicFile === null ? null : "assets/music.mp3";
|
|
572
602
|
const fonts = copyFonts(options.brand.fonts, join(assetsDir, "fonts"));
|
|
573
603
|
if (options.brand.logo !== null)
|
|
574
604
|
cpSync(options.brand.logo, join(assetsDir, "logo.svg"));
|
|
575
|
-
const sfx = {};
|
|
576
|
-
mkdirSync(join(assetsDir, "sfx"), { recursive: true });
|
|
577
|
-
for (const [event, source] of Object.entries(options.sfx)) {
|
|
578
|
-
const name = `${event}${extname(source)}`;
|
|
579
|
-
cpSync(source, join(assetsDir, "sfx", name));
|
|
580
|
-
sfx[event] = `assets/sfx/${name}`;
|
|
581
|
-
}
|
|
582
605
|
cpSync(require.resolve("gsap/dist/gsap.min.js"), join(assetsDir, "gsap.min.js"));
|
|
583
606
|
const base = resolveLayout(film.format, options.layout ?? {});
|
|
584
607
|
// A caption preset places the 9:16 box in a platform's safe zone; the project's own caption override still wins.
|
|
@@ -621,18 +644,47 @@ async function runRenderFootage(film, clips, transcript, edl, options) {
|
|
|
621
644
|
if (!rendered.ok)
|
|
622
645
|
return rendered;
|
|
623
646
|
const roles = Object.fromEntries(clips.map((clip) => [clip.clip.id, clip.clip.role]));
|
|
624
|
-
const finished = await finishFootage(film, { renderFile, seconds, coverAt: film.cover?.at ?? getDefaultCoverSeconds(edl, roles) }, options);
|
|
647
|
+
const finished = await finishFootage(film, { renderFile, seconds, coverAt: film.cover?.at ?? getDefaultCoverSeconds(edl, roles), mix: prepared.value }, options);
|
|
625
648
|
if (!finished.ok)
|
|
626
649
|
return finished;
|
|
627
650
|
return ok({ kind: "rendered", output: options.output, seconds, edlPath: getEdlPath(buildDir, options.isPlaceholder), declick, ...finished.value });
|
|
628
651
|
}
|
|
652
|
+
/** The film's mix target: `mixLoudness`, the default when absent, null when the film keeps the render's sound. */
|
|
653
|
+
function getMixLoudnessTarget(film) {
|
|
654
|
+
return film.mixLoudness === undefined ? DEFAULT_LOUDNESS : film.mixLoudness;
|
|
655
|
+
}
|
|
629
656
|
/**
|
|
630
|
-
* The
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
657
|
+
* The mix stage over a film's sound (`mixSource`, any file ffmpeg reads): measured, brought to `target` and encoded
|
|
658
|
+
* to `output` (AAC) by `finishMix`; null when the mix is silent (the final pass then keeps the render's sound). An
|
|
659
|
+
* error names the last measurement. `renderFootage` runs it before hyperframes renders a frame (issue #1124).
|
|
660
|
+
*/
|
|
661
|
+
export async function mixFootage(target, input, options) {
|
|
662
|
+
const aborting = options.signal === undefined ? {} : { signal: options.signal };
|
|
663
|
+
const measured = await measureLoudness(input.mixSource, target, { label: "the film's mix", ...aborting });
|
|
664
|
+
if (measured.kind === "silent") {
|
|
665
|
+
options.log("loudness: the film's mix is silent, left as it is.");
|
|
666
|
+
return ok(null);
|
|
667
|
+
}
|
|
668
|
+
const mixed = await finishMix({ input: input.mixSource, output: input.output, measurement: measured.measurement, target, ...aborting });
|
|
669
|
+
if (!mixed.ok) {
|
|
670
|
+
rmSync(input.output, { force: true });
|
|
671
|
+
return mixed;
|
|
672
|
+
}
|
|
673
|
+
const { attempt, tries, probes } = mixed.value;
|
|
674
|
+
const keep = target.keep ?? "loudness";
|
|
675
|
+
const mix = { measured: { integrated: measured.measurement.inputI, truePeak: measured.measurement.inputTp }, gainDb: attempt.gainDb, ceilingDbtp: attempt.ceilingDbtp, keep, encodes: tries };
|
|
676
|
+
const kept = keep === "speech" ? ` (speech kept: ${formatDb(target.target)} ± ${getMixTolerance(target)} LUFS)` : "";
|
|
677
|
+
options.log(`loudness: the film's mix measured ${formatDb(measured.measurement.inputI)} LUFS, true peak ${formatDb(measured.measurement.inputTp)} dBTP; ` +
|
|
678
|
+
`gain ${formatDb(attempt.gainDb)} dB${kept}, limiter at ${formatDb(attempt.ceilingDbtp)} dBTP (encode ${tries} of ${getMixAttempts(target)}, ${probes} uncompressed probes).`);
|
|
679
|
+
return ok({ audioFile: input.output, mix });
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The final pass over hyperframes' render: the film's mix (`input.mix`, prepared by `mixFootage` before the render;
|
|
683
|
+
* null keeps the render's sound; absent, the render's own sound goes through `mixFootage` here) muxed with the
|
|
684
|
+
* picture (copied where the render already matches; `finishVideo` re-encodes it to H.264 High at its preset and CRF),
|
|
685
|
+
* publishable codecs and fast start, checked with ffprobe, the finished file's sound measured and held to the target
|
|
686
|
+
* (a near miss inside `warnTolerance` finishes with `loudness.warning`), then the cover and the file's facts.
|
|
687
|
+
* Exported for tests only.
|
|
636
688
|
*/
|
|
637
689
|
export async function finishFootage(film, input, options) {
|
|
638
690
|
const { log, signal, output } = options;
|
|
@@ -642,29 +694,16 @@ export async function finishFootage(film, input, options) {
|
|
|
642
694
|
const rendered = await probeFilmFacts(input.renderFile, aborting);
|
|
643
695
|
if (!rendered.ok)
|
|
644
696
|
return err(`the rendered film: ${rendered.error}`);
|
|
645
|
-
const mixLoudness = film
|
|
646
|
-
let
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const mixed = await finishMix({ input: input.renderFile, output: audioFile, measurement: measured.measurement, target: mixLoudness, ...aborting });
|
|
656
|
-
if (!mixed.ok) {
|
|
657
|
-
rmSync(audioFile, { force: true });
|
|
658
|
-
return mixed;
|
|
659
|
-
}
|
|
660
|
-
const { attempt, tries } = mixed.value;
|
|
661
|
-
const keep = mixLoudness.keep ?? "loudness";
|
|
662
|
-
mix = { measured: { integrated: measured.measurement.inputI, truePeak: measured.measurement.inputTp }, gainDb: attempt.gainDb, ceilingDbtp: attempt.ceilingDbtp, keep };
|
|
663
|
-
const kept = keep === "speech" ? ` (speech kept: ${formatDb(mixLoudness.target)} ± ${getMixTolerance(mixLoudness)} LUFS)` : "";
|
|
664
|
-
log(`loudness: the film's mix measured ${formatDb(measured.measurement.inputI)} LUFS, true peak ${formatDb(measured.measurement.inputTp)} dBTP; ` +
|
|
665
|
-
`gain ${formatDb(attempt.gainDb)} dB${kept}, limiter at ${formatDb(attempt.ceilingDbtp)} dBTP (encode ${tries} of ${MIX_ATTEMPTS}).`);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
697
|
+
const mixLoudness = getMixLoudnessTarget(film);
|
|
698
|
+
let prepared = input.mix ?? null;
|
|
699
|
+
if (input.mix === undefined && mixLoudness !== null && rendered.facts.audio !== null) {
|
|
700
|
+
const mixed = await mixFootage(mixLoudness, { mixSource: input.renderFile, output: join(dirname(input.renderFile), "mix.m4a") }, { log, ...aborting });
|
|
701
|
+
if (!mixed.ok)
|
|
702
|
+
return mixed;
|
|
703
|
+
prepared = mixed.value;
|
|
704
|
+
}
|
|
705
|
+
const audioFile = prepared?.audioFile;
|
|
706
|
+
const mix = prepared?.mix ?? null;
|
|
668
707
|
const { finishVideo } = options;
|
|
669
708
|
const isVideoCopied = finishVideo === undefined && isPublishableVideo(rendered.facts.video);
|
|
670
709
|
const isAudioCopied = audioFile === undefined && (rendered.facts.audio === null || isPublishableAudio(rendered.facts.audio));
|
|
@@ -683,17 +722,20 @@ export async function finishFootage(film, input, options) {
|
|
|
683
722
|
if (finished.facts.audio !== null) {
|
|
684
723
|
const measured = await measureLoudness(output, mixLoudness ?? DEFAULT_LOUDNESS, { label: "the finished film", ...aborting });
|
|
685
724
|
if (measured.kind === "measured") {
|
|
686
|
-
|
|
725
|
+
const sound = { integrated: measured.measurement.inputI, truePeak: measured.measurement.inputTp };
|
|
687
726
|
// A mix left as rendered (`mixLoudness: null`) or silent is reported, not held to a target it was not brought to.
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
690
|
-
return err(`the finished film ${output} measures ${describeMixLoudness(
|
|
691
|
-
|
|
727
|
+
const verdict = mixLoudness === null || audioFile === undefined ? { kind: "pass" } : getLoudnessVerdict(sound, mixLoudness);
|
|
728
|
+
if (verdict.kind === "fail")
|
|
729
|
+
return err(`the finished film ${output} measures ${describeMixLoudness(sound)}: ${verdict.problems.join("; ")}.`);
|
|
730
|
+
loudness = { ...sound, warning: verdict.kind === "warn" ? `the finished film ${output}: ${verdict.warning}` : null };
|
|
731
|
+
log(`loudness: the finished film measures ${formatDb(sound.integrated)} LUFS, true peak ${formatDb(sound.truePeak)} dBTP.`);
|
|
732
|
+
if (loudness.warning !== null)
|
|
733
|
+
log(`loudness warning: ${loudness.warning}`);
|
|
692
734
|
}
|
|
693
735
|
}
|
|
694
736
|
progress(0, input.seconds);
|
|
695
737
|
const { bytes, width, height, durationSeconds } = finished.facts;
|
|
696
|
-
const streams = describeFinishStreams({ isVideoCopied, isAudioCopied, hasAudio:
|
|
738
|
+
const streams = describeFinishStreams({ isVideoCopied, isAudioCopied, hasAudio: finished.facts.audio !== null, ...(finishVideo === undefined ? {} : { finishVideo }) });
|
|
697
739
|
log(`finish: ${streams} to H.264 ${finished.facts.video.profile ?? ""}, AAC 48 kHz stereo, fast start; ${width}×${height}, ${durationSeconds.toFixed(2)} s, ${bytes} bytes.`);
|
|
698
740
|
let cover = null;
|
|
699
741
|
if (film.cover !== null) {
|
|
@@ -707,31 +749,45 @@ export async function finishFootage(film, input, options) {
|
|
|
707
749
|
return ok({ bytes, width, height, durationSeconds, cover, loudness, mix });
|
|
708
750
|
}
|
|
709
751
|
/**
|
|
710
|
-
* The mix's sound brought to `target` on its own
|
|
711
|
-
*
|
|
712
|
-
*
|
|
752
|
+
* The mix's sound brought to `target` on its own, at a fixed ceiling (issue #1124): the gain is solved on
|
|
753
|
+
* uncompressed passes (`solveMixGain`), then the mix is encoded to AAC and measured. While the encode misses, the
|
|
754
|
+
* ceiling is lowered only by its true peak excess (the codec's overshoot) and the gain solved again at it, shifted by
|
|
755
|
+
* the codec's measured loudness drift, at most `getMixAttempts` encodes. A last encode inside `warnTolerance` passes
|
|
756
|
+
* (the finished file's gate names the warning); otherwise an error names the last measurement.
|
|
713
757
|
*/
|
|
714
758
|
async function finishMix(input) {
|
|
715
759
|
const aborting = input.signal === undefined ? {} : { signal: input.signal };
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
760
|
+
const attempts = getMixAttempts(input.target);
|
|
761
|
+
const probe = async (attempt) => {
|
|
762
|
+
const probed = await measureLoudness(input.input, input.target, { label: "the film's mix through its limiter", filter: getMixFilter(attempt), ...aborting });
|
|
763
|
+
// A probe through a limiter on a mix that is not silent does not go silent; if it does, the encode reports it.
|
|
764
|
+
return probed.kind === "silent" ? { integrated: -Infinity, truePeak: -Infinity } : { integrated: probed.measurement.inputI, truePeak: probed.measurement.inputTp };
|
|
765
|
+
};
|
|
766
|
+
let ceilingDbtp = getFirstMixCeiling(input.target);
|
|
767
|
+
let startGainDb = getMixGain(input.measurement.inputI, input.target);
|
|
768
|
+
let shift = 0;
|
|
769
|
+
let probes = 0;
|
|
770
|
+
for (let tries = 1; tries <= attempts; tries += 1) {
|
|
771
|
+
const solved = await solveMixGain({ ceilingDbtp, startGainDb, target: input.target, shift, measure: probe });
|
|
772
|
+
probes += solved.probes.length;
|
|
773
|
+
const attempt = solved.best.attempt;
|
|
721
774
|
await runFfmpeg("The film's mix", buildMixArgs({ input: input.input, filter: getMixFilter(attempt), output: input.output }), { ...aborting, output: input.output });
|
|
722
775
|
const encoded = await measureLoudness(input.output, input.target, { label: "the film's encoded mix", ...aborting });
|
|
723
776
|
if (encoded.kind === "silent")
|
|
724
777
|
return err("the film's mix measures silent after its gain and limiter.");
|
|
725
|
-
measured = { integrated: encoded.measurement.inputI, truePeak: encoded.measurement.inputTp };
|
|
726
|
-
|
|
727
|
-
if (
|
|
728
|
-
return ok({ attempt, tries, measured });
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
778
|
+
const measured = { integrated: encoded.measurement.inputI, truePeak: encoded.measurement.inputTp };
|
|
779
|
+
const verdict = getLoudnessVerdict(measured, input.target);
|
|
780
|
+
if (verdict.kind === "pass" || (verdict.kind === "warn" && tries === attempts))
|
|
781
|
+
return ok({ attempt, tries, probes, measured });
|
|
782
|
+
if (tries === attempts) {
|
|
783
|
+
return err(`the film's mix still measures ${describeMixLoudness(measured)} after ${attempts} encodes (last: gain ${formatDb(attempt.gainDb)} dB, ` +
|
|
784
|
+
`limiter at ${formatDb(attempt.ceilingDbtp)} dBTP): ${verdict.kind === "fail" ? verdict.problems.join("; ") : ""}.`);
|
|
785
|
+
}
|
|
786
|
+
shift = Number.isFinite(solved.best.measured.integrated) ? measured.integrated - solved.best.measured.integrated : 0;
|
|
787
|
+
ceilingDbtp = getNextMixCeiling(attempt.ceilingDbtp, measured, input.target);
|
|
788
|
+
startGainDb = attempt.gainDb;
|
|
789
|
+
}
|
|
790
|
+
return err(`the film's mix was not encoded: mixLoudness.attempts is ${attempts}.`);
|
|
735
791
|
}
|
|
736
792
|
/** Both measurements of a mix, as an error names them. */
|
|
737
793
|
function describeMixLoudness(measured) {
|