Skip to content

Commit 66654cc

Browse files
committed
test(producer): build the loudness reference from the 16-bit track the mixer reads
1 parent c1fbba8 commit 66654cc

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

‎packages/producer/src/services/distributed/plan.test.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import {
6262
import { buildSyntheticRenderJob } from "./shared.js";
6363
import { assemble } from "./assemble.js";
6464
import { constrainAacTruePeak } from "../render/audioPadTrim.js";
65+
import { limitDeliveryPeaks } from "../render/audioDeliveryLimit.js";
6566

6667
function ffmpegOrThrow(args: string[]): void {
6768
const ffmpeg = spawnSync(getFfmpegBinary(), ["-nostdin", "-loglevel", "error", ...args]);
@@ -1072,7 +1073,7 @@ describe.skipIf(spawnSync(getFfmpegBinary(), ["-version"]).status !== 0)(
10721073
["-nostdin", "-i", join(stitched, "audio.m4a"), "-af", "volumedetect", "-f", "null", "-"],
10731074
{ encoding: "utf-8" },
10741075
);
1075-
expect(Number(/max_volume: (-?[\d.]+) dB/.exec(volume.stderr)?.[1])).toBeLessThan(-1);
1076+
expect(Number(/max_volume: (-?[\d.]+) dB/.exec(volume.stderr)?.[1])).toBeLessThanOrEqual(-1);
10761077

10771078
const withCfr = join(runRoot, "plan-stitch-cfr");
10781079
await buildLocalExecutionPlan(project, { ...config, cfr: true }, withCfr, {
@@ -1253,17 +1254,29 @@ describe.skipIf(spawnSync(getFfmpegBinary(), ["-version"]).status !== 0)(
12531254
expect(planned.chunkCount).toBe(1);
12541255
const delivered = join(runRoot, "loudness-delivered.mp4");
12551256
await assemble(planDir, [video], join(planDir, "audio.m4a"), delivered);
1257+
// Built as delivery is: the track read as 16-bit (the mixer does; noise encodes 0.4 dB hotter for it), float PCM
1258+
// fitted to the frames, then guardDeliveryPeaks: the peak limit, the whole-mix cut.
1259+
const referenceSource = join(runRoot, "loudness-reference-source.wav");
1260+
ffmpegOrThrow([
1261+
...[
1262+
"-i",
1263+
join(project, "tone.wav"),
1264+
"-af",
1265+
"aformat=sample_fmts=s16,apad,atrim=0:3.033333",
1266+
],
1267+
...["-c:a", "pcm_f32le", "-y", referenceSource],
1268+
]);
12561269
const reference = join(runRoot, "loudness-reference.m4a");
1257-
const encoded = await encodeAac(join(project, "tone.wav"), reference, 91 / 30, {
1258-
timeout: 30_000,
1259-
filter: "apad,atrim=0:3.033333",
1260-
});
1270+
const encoded = await encodeAac(referenceSource, reference, 91 / 30, { timeout: 30_000 });
12611271
expect(encoded.success, encoded.stderr).toBe(true);
1262-
const held = await constrainAacTruePeak({
1272+
const delivery = {
12631273
audioPath: reference,
1264-
sourcePath: join(project, "tone.wav"),
1274+
sourcePath: referenceSource,
12651275
targetDurationSeconds: 91 / 30,
1266-
});
1276+
};
1277+
const limited = await limitDeliveryPeaks({ ...delivery, timeoutMs: 60_000 });
1278+
expect(limited.success, limited.error).toBe(true);
1279+
const held = await constrainAacTruePeak(delivery);
12671280
expect(held.success, held.error).toBe(true);
12681281
const measure = (path: string) => {
12691282
const result = spawnSync(

0 commit comments

Comments
 (0)