Skip to content

Commit 63bc525

Browse files
committed
fix(engine): stop mux at shortest normalized stream
1 parent 5324615 commit 63bc525

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/engine/src/services/chunkEncoder.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ describe("muxVideoWithAudio audio codec handling", () => {
389389
);
390390

391391
await flushMuxCodecResolution();
392+
expect(calls[0]!.args).toContain("-shortest");
392393
expect(calls[0]!.args).toContain("-t");
393394
expect(calls[0]!.args).toContain("16.066667");
394395
emitClose(calls[0]!.proc, 0);

‎packages/engine/src/services/chunkEncoder.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,13 @@ export async function muxVideoWithAudio(
709709
args.push("-r", fpsToFfmpegArg(fps));
710710
}
711711
if (config?.durationSeconds !== undefined) {
712+
// Stream-copying a normalized AAC sidecar can preserve a longer packet
713+
// timeline than its container/edit-list duration. `-t` alone limits the
714+
// output timestamp window but does not prevent the copied audio stream's
715+
// tail from extending the MP4 timeline. When an explicit video-derived
716+
// duration is supplied, also stop at the shortest stream so the final
717+
// mux boundary is deterministic.
718+
args.push("-shortest");
712719
args.push("-t", String(config.durationSeconds));
713720
}
714721
args.push("-y", outputPath);

0 commit comments

Comments
 (0)