Repository navigation
fix(media-execution): tolerate AAC encoder delay in the final mux assertion - #298
Merged
rponeawa merged 1 commit intoSep 18, 2026
Merged
Conversation
…ertion The staged WAV is already asserted sample-exact, so this assertion is about what survives AAC. AAC cannot carry an arbitrary sample count: the encoder emits 1024-sample frames and reports a priming delay that the MP4 muxer compensates with an edit list, so the presented span lands a few samples away from the input. Measured with ffmpeg 6.1 on a synthetic tone, independent of any project's material: 4,249,600 samples in -> 4,249,584 presented (-16) 4,236,800 samples in -> 4,236,768 presented (-32) Padding the timeline to a whole number of AAC frames does not remove it, so this is not a frame-alignment artifact and cannot be fixed upstream of the encoder. Demanding exact equality therefore rejects every correct mux whose length is not a fixed point of that round trip. A real 88.5s vertical ad failed at step 54/55 this way with all generated material already paid for and stored. The invariant AAC can actually hold is that no whole frame of audio went missing, so the tolerance is one AAC frame rather than an arbitrary epsilon. Anything larger still means genuine desync and still fails, and the message now reports the signed sample delta instead of asserting a bare boolean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Merged
This was referenced Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #296.
The staged WAV is already asserted sample-exact a few lines earlier, so this assertion is about
what survives AAC. AAC cannot carry an arbitrary sample count: the encoder emits 1024-sample frames
and reports a priming delay that the MP4 muxer compensates with an edit list, so the presented span
lands a few samples away from the input.
Measured with ffmpeg 6.1 on a synthetic tone, independent of any project's material:
Padding the timeline to a whole number of AAC frames does not remove it, so this is not a
frame-alignment artifact and cannot be fixed upstream of the encoder.
Demanding exact equality therefore rejects every correct mux whose length is not a fixed point of
that round trip. The invariant AAC can actually hold is that no whole frame of audio went missing,
so the tolerance is one AAC frame rather than an arbitrary epsilon. Anything larger still means
genuine desync and still fails, and the message now reports the signed sample delta instead of
asserting a bare boolean.
pnpm checkpasses.pnpm testis unchanged by this commit; on this Windows machinepackages/cli/test/runtime-selection.test.tsfails identically on pristine v0.2.5, which looksunrelated (8.3 short path vs
process.cwd()).🤖 Generated with Claude Code