Skip to content

Commit afc4e96

Browse files
committed
fix(render): cap trimmed audio container duration
1 parent 9289551 commit afc4e96

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎packages/producer/src/services/render/audioPadTrim.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ describe("buildPadTrimAudioArgs", () => {
9191
expect(operation).toBe("trim");
9292
const filterIdx = args.indexOf("-af");
9393
expect(args[filterIdx + 1]).toBe("atrim=duration=15.000000,asetpts=PTS-STARTPTS");
94+
expect(args[args.indexOf("-t") + 1]).toBe("15.000000");
9495
const codecIdx = args.indexOf("-c:a");
9596
expect(args[codecIdx + 1]).toBe("aac");
9697
expect(args[args.indexOf("-b:a") + 1]).toBe("192k");

‎packages/producer/src/services/render/audioPadTrim.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ export function buildPadTrimAudioPlan(
201201
audioPath,
202202
"-af",
203203
`atrim=duration=${targetSec},asetpts=PTS-STARTPTS`,
204+
// `atrim` limits decoded samples but does not cap muxer timestamps
205+
// introduced by encoder delay/flush. The output duration contract
206+
// is enforced at the container boundary as well; without `-t`, a
207+
// long primed source can retain its original tail after re-encode.
208+
"-t",
209+
targetSec,
204210
"-c:a",
205211
"aac",
206212
"-b:a",

0 commit comments

Comments
 (0)