Repository navigation
fix(engine): audio encodes on FFmpeg 4.4, which has no setts duration option - #6219
Merged
Merged
Conversation
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 176 of thoseThe gate passes. Quarantined, measured but not gated (0) |
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 1 important · 1 nit · head e397d1d0
- important (pre-existing, but this PR's new test depends on it) — on FFmpeg 5.1 (Debian 12's default)
settshasduration, so the segmented path runs, but the stream doesn't end at the duration. Locally with 5.1.9,encodes a long mix in parallel segments…fails on main (7224288vs7224000). The new test fails the same way ataacEncode.test.ts:227: one-pass gives120000(exactly 2.5 s), the segmented reference gives120816. Your one-pass output is the correct one. Comparing to2.5 * 48000instead of the segmented reference would make the test pass on any host's FFmpeg. The 5.x end overshoot deserves its own follow-up. - nit —
aacEncode.ts:83: the one-pass encode drops-cpuflags 0, so on FFmpeg < 5 the bytes (and anything hashed from them) can differ between machines. Adding it keeps the property theMAX_SEGMENTScomment relies on.
Scope
The probe is cached per binary and fails open: on a probe error the segmented path runs and reports its own error. A missing setts (pre-4.4) also prints no duration, so those builds take the one-pass path too. The setts=duration in aacEncode.ts is the only setts use in packages/, and both callers (audioMixer.ts:1362, audioPadTrim.ts:598) go through encodeAac. Required CI was still running at review time.
miguel-heygen
enabled auto-merge
October 24, 2026 14:54
… option The segmented AAC encode ended its stream with setts=duration, added in FFmpeg 5.0, so every render with audio failed on Ubuntu 22.04's FFmpeg 4.4. An FFmpeg without the option now encodes the audio in one pass, which ends the stream at the duration itself.
miguel-heygen
force-pushed
the
fix/aac-end-on-old-ffmpeg
branch
from
October 24, 2026 15:49
e397d1d to
7f15da8
Compare
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.
Every render with audio failed at the audio mix on FFmpeg 4.4 (Ubuntu 22.04's
apt install ffmpeg, the install the docs give):setts_bsf: Option 'duration' not found, reported asaudio_processing_failed/ffmpeg_unsupported. The segmented AAC encode (0.8.170) joins its segments as ADTS, which carries no end, and ends the stream withsetts=duration=...; that option arrived in FFmpeg 5.0. The segmented path runs for every audio render, not only long ones.encodeAacnow asks the FFmpeg it will use whethersettshas adurationoption (once per binary). If it does, nothing changes: same segments, same bytes. If it does not, the audio is encoded in one pass, which ends the stream at the duration itself. That is slower on long mixes (one encoder, about 60x real time) and only affects FFmpeg older than 5.0. No minimum FFmpeg version is declared anywhere, and the docs point Ubuntu users atapt install ffmpeg, so 4.4 is supported in practice.Verified on a real FFmpeg 4.4.2 (Ubuntu 22.04 container on the devbox) with the CLI: a 2 s composition with one AAC clip,
render --fps 24 --workers 1. On main it fails with the reported error; with this change it renders, audio and video both 2.000 s. On the current FFmpeg the same render still takes the setts path.Tests: with a stub FFmpeg that rejects
setts=durationand prints nodurationin its help,encodeAacsucceeds and the stream ends at the same tick as the normal encode (fails on main). The existing byte-identity and segment tests pass unchanged (9/9).