Repository navigation
fix(playback): play MPEG-TS files with AAC audio over the web remux - #2698
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Quick104
left a comment
There was a problem hiding this comment.
Review of 76262fa. The fix is sound. On this host's FFmpeg 6.1.1, the remux arguments built on main fail on an MPEG-TS file with AAC audio ("Malformed AAC bitstream" after about 6 KB). The arguments from this branch stream the whole file. I found one gap, in the docs, and I'm fixing it in a commit on this branch, so there's no need to change it yourself.
Review summaryReviewed head: b5fc184 (76262fa plus one docs commit from this review) Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green) The fix is sound. On this host's FFmpeg 6.1.1, the remux arguments built on Addressed
Checked and found correct
Tests The new tests call the changed function signature, so they don't build on the base and can't show a failure there. The base failure above came from running the arguments each side builds. The new and changed tests pass on the head. Left for maintainers
Validated features No passed case on the v1.0 board reaches this code. #1252 C3 (resume across direct, remux and transcode) and C6 (mixed-format fixtures) exercise the remux path and haven't run yet. They should run on a build that includes this change. The PR body's User manual: no setting, default, label, or documented behavior changes, so the manual is unaffected. Apple/Android: server-only fix. Native clients that direct-play are unaffected and need no change. Fit: a playback correctness fix in the executor that owns the FFmpeg arguments. It keys on the copied codec rather than the container, which is the narrowest correct condition. Readiness: the base failure and the head fix were both reproduced by running the real argument builder. CI passed on 76262fa. The only new commit is docs. Review method: three finder passes plus a validation-impact check and a verifier (Claude, claude-opus-5-5), and one cross-provider round (Codex, gpt-6.1-sol). The cross-provider round found no regressions and independently found the HLS gap. |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
A progressive remux of an MPEG-TS source with AAC audio failed on the first audio packet. MPEG-TS carries AAC as ADTS, which MP4 cannot hold, and under delay_moov FFmpeg does not insert aac_adtstoasc on its own. The muxer stopped with "Malformed AAC bitstream", the browser received little more than the file header, and the web player went straight to the finished screen. Add -bsf:a aac_adtstoasc when the remux copies an AAC track. The filter passes raw AAC from MKV and MP4 through unchanged but rejects other codecs, so it keys on the planned audio codec, which for a copy is the source track's codec. The native stream handler, transcode nodes and proxies read it from the session or stream token; Jellycompat reads the selected track.
Jellycompat proxy tokens set the target audio codec to aac for every remux, including ones that copy AC-3 or E-AC-3, so a proxy reading that claim would add aac_adtstoasc to a non-AAC track and fail the stream. Tokens minted by older servers carry the same value, so a new proxy cannot trust it during a rolling upgrade. Carry the codec of the copied track in a new cac claim instead. Native remux tokens and Jellycompat proxy tokens set it only when audio is copied; a token without it keeps the plain copy.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
b5fc184 to
8650449
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
* fix(playback): convert copied ADTS AAC for fMP4 HLS segments An HLS copy remux of an MPEG-TS source with AAC audio stopped after init.mp4: the HLS muxer's fMP4 segments can't hold ADTS framing and FFmpeg does not insert aac_adtstoasc there on its own. TranscodeOpts now carries the copied source audio codec (CopyAudioCodec), and buildFFmpegArgs adds -bsf:a aac_adtstoasc when a copied AAC track goes into fMP4 segments. MPEG-TS segments and other codecs are unchanged. The filter check is shared with the progressive remux fix from #2698. The codec reaches every executor: the v3 integrated and remote-node starts, the recipe card and stream token (the existing cac claim), transcode rehoming, and the jellycompat integrated, node and proxy paths. An older node or token without the codec keeps the plain copy. Closes #2840 * refactor(playback): reuse TranscodesAudio for the copied HLS codec Drop a handler test that only checked its own fixture; the argument table, recipe card round trip and jellycompat token rows cover the behaviour. * fix(transcodenode): refuse nodes that ignore the copied audio codec A node from before this change ignores copy_audio_codec, so it copies AAC into fMP4 segments without aac_adtstoasc and the stream stops after the first segment. Nodes now return the copied codec in their start receipt, and the API rejects a node that doesn't confirm it, as a retryable start failure like the other recipe receipts. The check applies only when a copied AAC track goes into fMP4 segments, so older nodes still take MPEG-TS sessions and other copied codecs. The rule for when the filter applies is now one function, playback.HLSCopiesAACIntoFMP4, shared by the argument builder and the check. * fix(apiv2): regenerate OpenAPI for the copied audio codec receipt The transcode node start request and response schemas in the v2 contract gain the optional copy_audio_codec property. The node API doc describes the field and when the API requires the node to confirm it. * fix(playback): match copied audio in any case when adding aac_adtstoasc appendAudioArgs copies audio for "COPY" or " copy " too, so the fMP4 rule now uses TranscodesAudio rather than an exact "copy" match. * docs(transcodenode): say which paths check the copied audio codec receipt The receipt is checked only on POST /transcode/start. Jellycompat moves and node-side reconstruction skip it, and the check also refuses older nodes for MKV and MP4 AAC copies, so state that transcode nodes update first. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Quick104 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem
Related issue: N/A
Validation tasks: changes #1252 C3 and C6 (both not run yet)
MPEG-TS files with AAC audio do not play in the web app when the server remuxes them. The player flashes, then shows the "You've finished" screen. Stream captures such as Twitch VODs are the common case. Mobile clients that direct-play the file are unaffected. This change makes the remux convert the audio framing so these files play.
The progressive remux copies streams into fragmented MP4 with
-movflags frag_keyframe+delay_moov+default_base_moof. MPEG-TS carries AAC as ADTS, which MP4 cannot hold. FFmpeg normally insertsaac_adtstoascon its own, but not underdelay_moov. The muxer stops on the first audio packet:The response is HTTP 200 with almost nothing in it: about 300 KB from the start of the file and 1.3 KB after a resume. The video element reports a duration of 0 or 0.18 s and ends. FFmpeg 8.0.1 and jellyfin-ffmpeg 8.1.3, the version the Docker image ships, both fail this way. The progressive remux discards FFmpeg's stderr, so nothing shows up in the server log.
Approach
The remux adds
-bsf:a aac_adtstoascwhen it copies an AAC track. The filter passes AAC that is already raw (MKV, MP4) through unchanged, but FFmpeg refuses to open the output if it is applied to any other codec. So it keys on the codec of the copied track, not on the container.Every remux executor needs that codec. The integrated stream handler reads it from the session's planned audio codec, which for a copy is the source track's codec. Proxies and transcode nodes only see the stream token, so a new claim,
cac(CopyAudioCodec), carries it on the recipe card and in the token. It is set only when audio is copied. The existingtcaclaim could not be reused because Jellycompat proxy tokens set it toaacfor every remux, including AC-3 and E-AC-3 copies, and older servers mint those tokens too. A token withoutcackeeps the plain copy, so mixed-version fleets behave as before.Jellycompat's local remux and its proxy tokens take the codec from the selected source track, using the same track index the remux maps.
This affects the native web app, Jellycompat clients whose remux uses the same path, and proxy or transcode-node deployments. Native clients need no change.
Validation
mainit shows the finished screen in both cases. The reporter's sample file behaves the same.mainwith the error above and passes here.go build,go vet ./..., gofmt,make lint-changed,make lint-router-recovery, and the Go-side verify targets (local paths, route inventory, playback fixtures, apiv2 OpenAPI, contract, and fixtures, v1 route freeze, bidi, size ratchet, case collisions) pass.make test-go: the touched packages pass. Local failures in DB-backed tests in other packages also fail onmainwith the same local database. CI is the reference for those.make verify-settings-bindings-allpassed its Go half and could not run its web half withoutnode_modules.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2698/
Surface and build: web app, desktop, synthetic MPEG-TS test file at Original quality. Before is
mainat 365e3d4, after is this branch. Before: the player ends at once and shows the finished screen. After: the remux streams and plays.Risks
aacbut whose stream is something else would now fail at startup. The codec comes from the scan's probe of the same track the remux maps, so this needs a file that changed after its last scan.delay_moovbehavior could affect other ADTS sources, such as raw.aacfiles. Those go through the same filter when their codec is AAC.Checklist
AI Disclosure
aacfor remuxes that copy non-AAC audio, which would have made a proxy fail AC-3 and E-AC-3 copies. The fix moved the codec to the dedicatedcacclaim. A second round on the revised diff by both reviewers found nothing.Note
Apply AAC ADTS-to-ASC bitstream filter for copied AAC audio in remuxes
buildRemuxArgsWithLeadingPictureDropV3when the copied source codec is AAC, as documented in playback-protocol-v3.mdCopyAudioCodecfield onRecipeCardandRemuxServeOptions, acacclaim in token.go, and population at each call site in the API, proxy, transcode-node, and jellycompat handlersCopyAudioCodecvalue being present and correctly cased/trimmed; older executors ignore it and HLS playback of copied AAC remains a known limitationMacroscope summarized 8650449.