Repository navigation
fix(playback): normalize macOS Firefox HEVC resume boundaries - #659
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (16)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughPlayback V3 now flags eligible macOS Firefox HEVC progressive remuxes for a best-effort leading-picture drop. The setting persists through session and recipe state into stream claims. Remux execution applies the filter only for seeked video when the selected FFmpeg binary supports it. ChangesHEVC resume leading-picture drop
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue remains for the HEVC resume change after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is narrowly scoped, with no demonstrated new access to other users’ media or arbitrary command execution. Older servers can omit the correction, and deployment compatibility is only partly established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The implementation satisfies the main playback boundary in [ Resolution Use the shared named and versioned remux recipe or transformation contract for this filter. Advertise and validate the Full details: Docstring CoverageExplanation Docstring coverage is 39.66% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 58 functions across 24 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Normalize seeked HEVC copy boundaries for macOS Firefox while preserving the protocol-v3 player offset and scoping the recipe to progressive remux. Co-Authored-By: OpenAI Codex (gpt-5) <[email protected]>
5e10de9 to
e262a88
Compare
Review: four findings, plus a merge-order conflict with #657Reviewed every hunk against the PR head, built it, and ran Clean on inspection: the boundary arithmetic, the 1. Freezing the recipe on plain stream-copy plans breaks previously-working local playback —
|
|
Merge-order decision: #657 will land first. I’ve pushed its review fixes in I’ll keep #659 separate until #657 is merged, then rebase #659 onto the updated |
The original remux-v3 route, rfv/svc token claims and required transformation conflict with the recipe plumbing main has gained since (copy-fMP4 and tone-map recipe versions, vbsf, node-routed remux). This merge takes main's tree as is; the following commits re-implement the macOS Firefox HEVC resume fix on top of main's existing remux path.
A seeked progressive copy of an open-GOP HEVC source starts on a CRA whose RASL pictures reference frames the copy never sent, and macOS Firefox rejects the stream there (Silo-Server#658). The planner now freezes a best-effort request for that client into the session, recipe card, executable recipe and stream token, and the remux executor adds noise=drop=lt(pts\,startpts)*not(key) only when it starts past zero and its FFmpeg supports the drop expression (probed once per binary). Unlike the original version of this PR, the drop is not a plan transformation or required capability, so it never narrows the executor pool during a rolling upgrade, and a start at zero never probes or fails on an FFmpeg without the filter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
|
The PR body is missing the required
Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
|
@Quick104 thanks for the review, and sorry it sat so long. #657 was closed, so the merge-order question went away, but The drop is now a best-effort flag (
The filter string is unchanged from the one you validated. I haven't re-run the Firefox A/B against this version. The description has the details and test coverage. |
…frame (#3213) * fix(playback): start macOS Firefox HEVC resumes on an IDR A resumed or scrubbed progressive remux starts on the keyframe before the seek. In an open-GOP encode that keyframe is a CRA, and macOS Firefox buffers nothing from a stream that does not start on an IDR, so resume and scrubbing spun until the player gave up. Dropping the CRA's leading pictures (#659) was not enough. When the resume leading-picture drop runs, the remux now takes its video from an ffconcat list: the source's first frame, which is an IDR sharing the file's parameter sets, held for 1 ms, then the source from the seek's keyframe. Audio still comes from the seeked input, offset to the keyframe. A failed probe falls back to the plain seeked copy. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(playback): keep the IDR primer to one frame FFmpeg's concat demuxer checks the outpoint against DTS, so in an encode with deep B-frame reordering several frames after the source's IDR pass the primer's 1 ms outpoint and reach the client ahead of the seek's keyframe. A primed copy now uses a drop expression that counts keyframes and keeps only the IDR before the second one, along with that keyframe's leading pictures. A seek that lands on the first keyframe gets no primer, since the copy already starts there, and the two raw timestamp probes run under the same timeout as the seek anchor probe. A real-FFmpeg test covers an open-GOP B-pyramid encode resumed past and inside its first GOP. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(playback): schedule the IDR primer probes with the seek anchor probe The two raw timestamp probes for the IDR primer now share the seek anchor probe's singleflight group, four-slot limit and timeout, so concurrent primed starts no longer launch uncapped FFmpeg probes. A path whose decoded form holds a NUL is now also kept out of the ffconcat list. The real-FFmpeg primer test now checks that the picture after the primer is the source frame at the resolved anchor, including a resume requested exactly on a Matroska keyframe. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(playback): prime only CRA starts in indexed containers The IDR primer ran for every macOS Firefox HEVC resume. An MPEG-TS source lost its video: the concat demuxer's inpoint seek on TS skips the first IDR, so the keyframe-counting drop removed every packet, including on closed-GOP files that play on main. A closed-GOP seek already starts on an IDR and gained nothing from the primer but two extra probes and a second read of the source. A keyframe decoded right after the first frame passed the 1 ms outpoint and was counted as the seek's keyframe, which let the real one's leading pictures through and broke decoding. - Prime only Matroska and MP4-family sources, the containers whose index the concat demuxer seeks by. - The raw anchor probe now runs filter_units over the copy's first packet. An IDR comes out empty and is dropped, so a non-key first packet, or none within a second of the seek, means the copy already starts on an IDR and the primer is skipped after one probe. The one-second read bound keeps an all-IDR encode from being scanned to the end. - The primed drop finds the seek's keyframe within 3 ms of its 1 ms offset from the primer instead of by keyframe count. The window covers time bases too coarse for 1 ms, such as a 1/500 MP4 track. - The ffconcat path quoting moves to fspath.FFConcatFileURL, shared with mediasample. - The protocol doc describes the primer. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(playback): find the IDR primer in the Matroska Cues, not FFmpeg probes The primer ran up to three FFmpeg probes one after another before the remux started, each able to wait up to 15 s on the copy-seek pool. On stalled storage a macOS Firefox resume could wait about 45 s before it fell back, and the probes held slots jellycompat's seeked HLS starts need. The plan already resolves the keyframe its timeline starts on. It now adds that origin to the progressive stream URL as `origin`, and every executor (API stream, proxy, transcode node) passes it to the remux. The executor finds the origin's keyframe and the first one in the source's Matroska Cues (keyframes.Load, cached per file version), and reads the first slice of each block to check that the first is an IDR and the origin's is not. No FFmpeg runs for it. The lookup has a 300 ms budget, at most eight run at once, and a miss, an overrun or a full set of slots serves the plain copy at once. Audio arguments are unchanged, and the primed output matches the probed one packet for packet. Sources without usable Cues (MP4, MPEG-TS) and URLs without `origin` get the plain copy. The probe helpers in copy_seek_anchor.go go back to main. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Brady3035 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Quick <[email protected]>
Problem
Closes #658
Related issue: N/A
Validation tasks: changes #1252 C3 (resume and seek on the remux path, currently Not run)
On macOS Firefox, resuming an HEVC
server_remux_progressivestream can fail before the browser decodes a frame. A seeked stream copy starts at the keyframe before the requested position. For open-GOP HEVC that keyframe can be a CRA whose leading (RASL) pictures reference frames the copy never sent, and Firefox's VideoToolbox path rejects the stream at that boundary instead of skipping them.I reproduced this on
mainwith headed Firefox 153.0.4. With the same source, timestamp, chunked fMP4 transport and browser seek, the unfiltered stream reachedMEDIA_ERR_DECODEwith zero decoded frames. Adding onlynoise=drop=lt(pts\,startpts)*not(key)producedseekedandplaying, with 59 decoded frames, none dropped and no media error. The raw A/B output is in #658. Currentmain's planner still picks progressive remux for this client and source, so the bug is still reachable.Approach
This is a re-implementation on current
main. The original version of this PR added a versioned server transformation, a/stream/remux-v3/route and its ownrfv/svctoken claims. Since thenmainhas routed remux through proxy and transcode nodes and gained its own recipe plumbing, and #657 (which this PR was sequenced behind) was closed. Rather than resolve 33 conflicts into a second versioning scheme, the merge commit takesmain's tree and the fix is rebuilt onmain's existing remux path.RemuxResumeLeadingPictureDropon the progressive remux result. It is frozen into the session stream state, the remux recipe card, the executable recipe (so a seek reanchor keeps it) and the stream token (rlpd), the same wayRemuxDVModetravels.dovi_rpu=strip=1for Profile 7.noisefilter takes thedropexpression, cached per binary path like the existingdovi_rpuprobe. An FFmpeg without it serves the plain copy.How Quick104's four findings are handled:
planRequiresServerTransformationsV3and node-pool narrowing never see it. A start the API node could serve before is still served.ReconstructSessioncopied the filter onto transcode cards. There is no separate filter/version pair to reconstruct. The flag is a single bool that is only read on the remux path, so it can't form an invalid pair on a transcode card.media_files, so catalog drift can't turn a live session into a 409.Jellyfin compatibility is out of scope: jellycompat streams don't go through the v3 planner's device context, and #658 is about Silo's web client. No web, Apple or Android change is needed.
Validation
go test ./internal/playback/... ./internal/streamtoken/... ./internal/proxy/... ./internal/transcodenode/... ./internal/api/handlers/ -count=1andgo veton the same packages pass.internal/transcodenodetimed out once when run alongside the other packages and passed on three reruns on its own.9dc36a76passed: Go test, Go integration, Go lint, Go contract checks, Go DB pins and repository checks (run).-dropprobe against a real FFmpeg binary (there's no FFmpeg on the machine I used). The filter string is the one from the [bug] macOS Firefox fails HEVC progressive-remux resume at an open-GOP boundary #658 A/B, which Quick104 also checked against real open-GOP HEVC media, including the escaped comma when chained withdovi_rpu=strip=1. The probe looks for the same-dropoption the deployed Jellyfin FFmpeg lists under-h bsf=noise.Benchmarks
Not applicable. This changes which bitstream filter runs on one client's seeked remux. The only added cost is one cached
ffmpeg -h bsf=noiseprobe per binary.Risks
An FFmpeg build without the
dropexpression keeps today's behaviour for this client: the plain copy, which can still fail on macOS Firefox at an open-GOP boundary. Nothing else changes for other clients, codecs or deliveries.Checklist
AI Disclosure
main, mergedmain, re-implemented the fix onmain's remux plumbing, and wrote and ran the tests.PlayRemuxplanner result is audio-only and doesn't need the flag.