Skip to content

fix(media-execution): preserve AAC tail for non-integer frame rates - #317

Merged
rponeawa merged 1 commit into
hypit-ai:mainfrom
Flandern1211:fix/mux-ntsc-audio-tail
Sep 19, 2026
Merged

rponeawa merged 1 commit into
hypit-ai:mainfrom
Flandern1211:fix/mux-ntsc-audio-tail

Conversation

@Flandern1211

@Flandern1211 Flandern1211 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #315

What this fixes

executeMuxProgramMedia passed -frames:v <frameCount> while stream-copying the already-validated
visual and encoding the TimelineAudio to AAC. FFmpeg treats that frame limit as a mux sync limit,
so non-integer frame rates such as 30000/1001 can drop the final AAC packet even though the audio
and visual inputs are valid.

On Windows with FFmpeg 9.0.1, a 913-frame 30000/1001 visual and its exact 1,462,261-sample
TimelineAudio produced only 1,461,248 presented samples (missing 1,013 samples). FFmpeg 6.x/7.x
can exceed the assertion tolerance and fail the final Build instead.

The visual frame count is already asserted before muxing. Removing the redundant mux frame limit
lets the AAC stream preserve the complete TimelineAudio while retaining the existing video-domain
validation and AAC-delay tolerance.

Test evidence

node --import tsx --test packages/provider-media-local/test/provider.test.ts
# tests 15, pass 15, fail 0

The regression test uses a real FFmpeg-generated 913-frame 30000/1001 visual, an exact 48 kHz
TimelineAudio artifact, and the local Provider's actual mux-program-media handler. It asserts
that AAC coding frames cover all 1,462,261 samples and that the presentation span remains within
64 samples of the authoritative TimelineAudio, allowing the normal cross-version AAC edit-list
rounding while catching the 1,013-sample truncation.

Verification

  • pnpm check — pass
  • node --import tsx --test packages/provider-media-local/test/provider.test.ts — 15 pass, 0 fail
  • git diff --check — pass
  • Full pnpm test was attempted after a frozen offline install; the suite reached unrelated
    long-running HyperFrames process/capture tests on this Windows host and was interrupted, so no
    full-suite pass claim is made here.

@Flandern1211
Flandern1211 force-pushed the fix/mux-ntsc-audio-tail branch from 259fcbb to 3a17155 Compare September 19, 2026 07:50
@Universeyi

Copy link
Copy Markdown

Thanks for picking this up — and for the Windows / 9.0.1 number, which matches what I measured on macOS exactly (1,461,248 presented samples, −1013).

I checked the branch on ffmpeg 6.1.6, 7.1.5 and 9.0.1 (macOS arm64):

6.1.6 7.1.5 9.0.1
new test on this branch pass pass pass
same test with the -frames:v line restored fail (mux aborts, −1045) fail (−1045) fail (the test's own span assert, −1013)
all 8 lengths from #315 + 3 controls through executeMuxProgramMedia 11/11 accepted 11/11 11/11
whole provider.test.ts 15/15 14/15 15/15

So the regression test is red without the fix on the ffmpeg generations CI installs, which was the objection to the test offered in #283. The one failure on 7.1.5 is the StillVideo test, unrelated to this change (#316).

Two things worth knowing before merging, both written up in #315: the media-pipeline mux producer currently refuses these lengths one step earlier (exact-equality check), so this path is only reachable when the capability is called directly; and executeTransformMedia has the same -c:a aac + -frames:v shape without any span assertion.

@rponeawa
rponeawa merged commit 62da67d into hypit-ai:main Sep 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Final mux: -frames:v makes ffmpeg drop the last AAC packet at 30000/1001 and 60000/1001, so the span assertion aborts correct muxes on ffmpeg 6/7

3 participants