fix(engine): stop mux at shortest normalized stream

This commit is contained in:
Miguel Ángel
2026-07-25 21:14:18 +00:00
parent 532461599b
commit 63bc525ca9
2 changed files with 8 additions and 0 deletions
@@ -389,6 +389,7 @@ describe("muxVideoWithAudio audio codec handling", () => {
);
await flushMuxCodecResolution();
expect(calls[0]!.args).toContain("-shortest");
expect(calls[0]!.args).toContain("-t");
expect(calls[0]!.args).toContain("16.066667");
emitClose(calls[0]!.proc, 0);
@@ -709,6 +709,13 @@ export async function muxVideoWithAudio(
args.push("-r", fpsToFfmpegArg(fps));
}
if (config?.durationSeconds !== undefined) {
// Stream-copying a normalized AAC sidecar can preserve a longer packet
// timeline than its container/edit-list duration. `-t` alone limits the
// output timestamp window but does not prevent the copied audio stream's
// tail from extending the MP4 timeline. When an explicit video-derived
// duration is supplied, also stop at the shortest stream so the final
// mux boundary is deterministic.
args.push("-shortest");
args.push("-t", String(config.durationSeconds));
}
args.push("-y", outputPath);