Skip to content

fix(playback): normalize macOS Firefox HEVC resume boundaries - #659

Merged
Quick104 merged 4 commits into
Silo-Server:mainfrom
blurbery:fix/issue-658-firefox-hevc-resume
Oct 7, 2026
Merged

Quick104 merged 4 commits into
Silo-Server:mainfrom
blurbery:fix/issue-658-firefox-hevc-resume

Conversation

@blurbery

@blurbery blurbery commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

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_progressive stream 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 main with headed Firefox 153.0.4. With the same source, timestamp, chunked fMP4 transport and browser seek, the unfiltered stream reached MEDIA_ERR_DECODE with zero decoded frames. Adding only noise=drop=lt(pts\,startpts)*not(key) produced seeked and playing, with 59 decoded frames, none dropped and no media error. The raw A/B output is in #658. Current main'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 own rfv/svc token claims. Since then main has 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 takes main's tree and the fix is rebuilt on main's existing remux path.

  • Best effort, not a required capability. For macOS Firefox and an HEVC source, the planner sets RemuxResumeLeadingPictureDrop on 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 way RemuxDVMode travels.
  • Applied only where it can matter. The executor adds the filter only when the response starts past zero and has video. It is chained ahead of dovi_rpu=strip=1 for Profile 7.
  • Probed once per binary. The executor checks that its FFmpeg's noise filter takes the drop expression, cached per binary path like the existing dovi_rpu probe. An FFmpeg without it serves the plain copy.
  • Old nodes are unaffected. The new claim and recipe fields are additive JSON. A proxy, transcode node or replica that predates them ignores the claim and serves the plain copy, which is today's behaviour.

How Quick104's four findings are handled:

  1. Freezing the recipe broke local playback during a rolling upgrade. The drop is no longer a plan transformation, so planRequiresServerTransformationsV3 and node-pool narrowing never see it. A start the API node could serve before is still served.
  2. The revalidation probe was uncached and ran at seek 0. The probe is cached per binary and only runs when the filter would be applied (seek past zero, video present). A start at zero never probes and never fails on an FFmpeg without the filter.
  3. ReconstructSession copied 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.
  4. The local path re-derived the codec from live catalog rows. The codec decision happens once, at planning, and is frozen into the session. The executor never re-reads 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=1 and go vet on the same packages pass. internal/transcodenode timed out once when run alongside the other packages and passed on three reruns on its own.
  • The new tests cover the remux arguments (the filter is added only for a seeked video copy, never at zero or for audio-only, and goes ahead of the DV7 strip) and the planner scope (macOS Firefox with HEVC on progressive remux sets the flag; Windows Firefox, macOS Safari and non-HEVC sources don't; the drop never appears in plan transformations). They also cover the flag surviving the recipe card, stream claims, executable recipe, session snapshot and restore, and the identity card that signs proxy tokens, and they pin the exact filter string.
  • GitHub Actions on 9dc36a76 passed: Go test, Go integration, Go lint, Go contract checks, Go DB pins and repository checks (run).
  • Not run this round: the Firefox A/B against this re-implementation, and the -drop probe 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 with dovi_rpu=strip=1. The probe looks for the same -drop option 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=noise probe per binary.

Risks

An FFmpeg build without the drop expression 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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (this round); OpenAI Codex desktop (original version)
  • Tool(s): Claude Code; OpenAI Codex
  • Model(s): claude-opus-5-5 (this round); gpt-5 (original version)
  • Involvement: AI-assisted. I directed the task and designed the work, and I ran the real macOS Firefox A/B in [bug] macOS Firefox fails HEVC progressive-remux resume at an open-GOP boundary #658. For this round, Claude Opus checked the planner on current main, merged main, re-implemented the fix on main's remux plumbing, and wrote and ran the tests.
  • Adversarial review: each of Quick104's four findings was checked against the new design (see above). A follow-up review confirmed that older nodes decode the new token and recipe fields leniently, and that the other PlayRemux planner result is audio-only and doesn't need the flag.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 01622b39-2d97-4582-af26-d1d48c5f6015

📥 Commits

Reviewing files that changed from the base of the PR and between e262a88 and 51b52b2.

📒 Files selected for processing (16)
  • docs/architecture/playback-protocol-v3.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_leading_picture_test.go
  • internal/api/handlers/playback_v3.go
  • internal/api/handlers/stream.go
  • internal/playback/device_quirks_v3.go
  • internal/playback/executable_recipe_v3.go
  • internal/playback/plan_v3.go
  • internal/playback/recipecard.go
  • internal/playback/remux.go
  • internal/playback/remux_leading_picture_test.go
  • internal/playback/session.go
  • internal/playback/transcode_manager.go
  • internal/proxy/server.go
  • internal/streamtoken/token.go
  • internal/transcodenode/server.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Playback 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.

Changes

HEVC resume leading-picture drop

Layer / File(s) Summary
Eligibility and playback planning
internal/playback/device_quirks_v3.go, internal/playback/plan_v3.go, internal/playback/remux_leading_picture_test.go
The planner sets the flag for eligible macOS Firefox HEVC progressive remuxes. Tests cover client and codec eligibility and confirm that the flag is not a required transformation.
Recipe and session state propagation
internal/playback/executable_recipe_v3.go, internal/playback/recipecard.go, internal/playback/session.go, internal/streamtoken/token.go, internal/playback/transcode_manager.go, internal/api/handlers/playback.go, internal/api/handlers/playback_v3.go, internal/api/handlers/playback_leading_picture_test.go, internal/playback/remux_leading_picture_test.go
The flag is preserved across recipes, claims, session state, reconstruction, and snapshots. Tests cover claim and state round trips.
Conditional remux filter execution
internal/playback/remux.go, internal/api/handlers/stream.go, internal/proxy/server.go, internal/transcodenode/server.go, internal/playback/remux_leading_picture_test.go, docs/architecture/playback-protocol-v3.md
Serving passes the flag to remux execution. Execution checks FFmpeg support and applies the filter only to seeked video remuxes; otherwise it serves a plain copy. Tests cover argument selection and filter composition. The protocol documentation describes the behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to 51b52

No actionable merge-blocking issue remains for the HEVC resume change after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 51b52

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is media processing within an authorized playback route, potentially executed by the API, proxy or selected worker. The added boolean does not itself select a filesystem path, executor identity or arbitrary command; those remain separate session and signed-routing inputs.

Trust Boundaries and Controls

  • observed — The API path checks authenticated session ownership and profile ownership before resolving the session’s media file. Recovery checks URL/session identity and rejects a caller different from the recipe owner. These controls precede the new option’s local remux handoff.
  • observed — The worker verifies the signed token, binds transport and execution routing, approves the input path and checks active progressive-remux authority before executing. Its lifecycle registration rejects an already-active transport and removes only the matching request generation on cleanup. The proxy remux route also passes through playback-token, egress and endpoint checks.

Resilience and Maintainability Implications

  • observed — Session reads return copies under a read lock, full updates increment the stream revision, and rollback requires the exact applied revision. These controls prevent the new flag from being read as an independently mutable field or restored by an obsolete replacement rollback.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The implementation satisfies the main playback boundary in [#658]. It limits the request to macOS Firefox HEVC progressive remux, applies the filter only when seekSeconds > 0, preserves the browser … Use the shared named and versioned remux recipe or transformation contract for this filter. Advertise and validate the noise drop capability for every eligible executor. Prevent the qualifying route from serving an unfiltered copy when th…
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changed files support [#658]. They add planner matching, remux argument construction, recipe and session propagation, token handling, capability probing, documentation, and focused tests. The filt…
Title check ✅ Passed The title clearly identifies the playback fix for macOS Firefox HEVC resume boundaries and matches the main changeset.
Description check ✅ Passed The description directly explains the HEVC resume failure, the best-effort remux fix, affected clients, implementation details, validation, risks, and scope.
Full details: Linked Issues check

Explanation

The implementation satisfies the main playback boundary in [#658]. It limits the request to macOS Firefox HEVC progressive remux, applies the filter only when seekSeconds > 0, preserves the browser seek, and adds propagation and argument tests. It does not satisfy the issue's suggested coding contract. The request is an unversioned boolean (RemuxResumeLeadingPictureDrop, claim rlpd), not a named, versioned server transformation. The executor treats noise -drop as best effort and silently serves an unfiltered copy when the selected binary lacks the filter. It does not advertise the capability or fail closed for local and remote executors.

Resolution

Use the shared named and versioned remux recipe or transformation contract for this filter. Advertise and validate the noise drop capability for every eligible executor. Prevent the qualifying route from serving an unfiltered copy when that required capability is unavailable. Add tests for the version, capability advertisement, and fail-closed behavior.

Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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]>
@blurbery
blurbery force-pushed the fix/issue-658-firefox-hevc-resume branch from 5e10de9 to e262a88 Compare August 16, 2026 10:12
@blurbery
blurbery marked this pull request as ready for review August 16, 2026 10:21
@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Aug 16, 2026
@Quick104

Copy link
Copy Markdown
Contributor

Review: four findings, plus a merge-order conflict with #657

Reviewed every hunk against the PR head, built it, and ran go vet plus the playback, proxy, api, and api/handlers suites — all pass. I also validated the new FFmpeg recipe empirically against a real open-GOP HEVC file: noise=drop=lt(pts\,startpts)*not(key) does drop exactly the one leading picture, and the escaped comma parses correctly when chained with dovi_rpu=strip=1.

Clean on inspection: the boundary arithmetic, the seekSeconds > 0 gate, token/claim symmetry (vbsf / rfv / svc produced in identityStreamURLV3, consumed in proxy.handleRemux), route registration on both the API router and the proxy, and the device-quirk matcher (web + firefox/ + not seamonkey/ + macintosh|mac os x, all lowercased). The progressivePlan := plan copy in plan_v3.go is also safe — the HLS branch re-applies its own subtitle decision and re-finalizes plan identity, so nothing is lost by no longer mutating plan.

1. Freezing the recipe on plain stream-copy plans breaks previously-working local playback — internal/api/handlers/playback_v3.go:1011 (medium)

Freezing the recipe onto plans that need no transformation makes planRequiresServerTransformationsV3 true, so refuseLocalIdentityWorkV3 now refuses playback the API node could serve itself.

Repro: cluster with playback.local_transcode_fallback=false, proxy nodes still on the pre-PR binary (i.e. any rolling upgrade). A macOS Firefox user plays HEVC/AAC MP4 from position 0 — no audio conversion, no DV strip. Before this PR plan.Transformations was empty, refuseLocalIdentityWorkV3 returned nil, and a plain -c copy remux served from the API node. Now the plan carries server_hevc_resume_leading_picture_drop, planIdentityProxySessionV3 narrows the pool to nodes advertising it (none), ProxyNode is nil, and the start fails with capacity_unavailable.

The refusal is self-contradictory in this case: the planner only formed the candidate because firefoxResumeAvailableLocal (plan_v3.go:402) proved the local ffmpeg carries the recipe — and at seek 0 the filter is never even added to argv, since remux.go:188 requires seekSeconds > 0.

2. The revalidation probe is uncached and fires even when the filter won't be applied — internal/playback/remux.go:278 (medium)

supportsHEVCResumeLeadingPictureRecipeV3 forks ffmpeg -h bsf=noise on every remux start with no per-binary cache, unlike supportsDoviRPUFilter (remux.go:57) which caches the identical -bsfs probe. Once the recipe is frozen, opts.VideoBitstreamFilter is non-empty on every subsequent request, so each HEAD preflight, each GET, and each reconnect/seek forks an extra synchronous ffmpeg (up to a 3s timeout) before the real remux starts.

Worse than latency, though: the check fires whenever opts.VideoBitstreamFilter != "" even at seekSeconds == 0, where buildRemuxArgsWithVideoBitstreamFilterV3 (:187) would not apply the filter at all. So on an ffmpeg build lacking noise, playback from the start fails with a 500 despite never needing the option.

3. ReconstructSession copies the filter onto transcode cards, producing a pair the validator rejects — internal/playback/transcode_manager.go:420 (low, latent)

It copies card.VideoBitstreamFilter into Session.RemuxFilter for every play method. A DV7 HLS-remux/copy session stores a card via NewRecipeCard with VideoBitstreamFilter = "dovi_rpu=strip=1" and RemuxFilterVersion = "" (recipecard.go:102 — the version field is only ever set by identityRecipeCard). After a restart the reconstructed session carries exactly the combination that makes ServeRemuxWithOptions return HTTP 409 "stale remux recipe" (remux.go:414).

Latent today: such cards reconstruct as PlayTranscode and HandleStream rejects that branch with a 400 before reaching the remux path. So this is a missing guard rather than a live bug — but it's the kind that becomes live the moment the reconstruct path grows a case.

4. The local path re-derives the codec from live catalog rows instead of the frozen recipe — internal/api/handlers/stream.go:172 (low)

sourceVideoCodec is recomputed from the live media_files row rather than read from the frozen recipe, so catalog drift turns a live session into a hard 409 instead of a replan. A rescan that rewrites media_files.video_tracks[0].codec — or clears video_tracks so the stale aggregate codec_video becomes authoritative, which this PR's own test at playback_v3_test.go:3825 deliberately sets up as disagreeing — makes validateRemuxVideoBitstreamFilterV3 fail. ServeRemuxWithOptions then writes a plain-text 409 with no JSON error envelope and no terminal reason the client can act on, and handleTransportStartFailure only logs.

The proxy path doesn't have this exposure because it reads the codec from the signed token — which is the argument for the local path reading it from the frozen recipe too.

Merge-order conflict with #657

This PR and #657 independently add two different versioning mechanisms for the same problem: rfv / RemuxFilterVersion + VideoBitstreamFilter / SourceVideoCodec and a new /stream/remux-v3/ route here, versus dvrv / RemuxDVRecipeVersion + RemuxServeOptions.DVRecipeVersion there. They conflict textually in 10 files: remux.go, protocol_v3.go, recipecard.go, session.go, playback_v3.go, stream.go, transformations_v3.go, proxy/server.go, cmd/playbackfixtures/main.go, and the protocol doc.

Whichever lands second needs a real rebase rather than a conflict resolution, and the pair should probably converge on one recipe-version claim instead of two. Finding 3 above and #657's Profile 8 fall-through are the same class of bug — a version field empty where a consumer requires it non-empty — so collapsing the schemes would likely eliminate both rather than needing two separate fixes. Your RemuxFilterVersion / VideoBitstreamFilter shape is the more general one ("any bitstream filter"), which is worth weighing when picking a direction.

I've deliberately left this PR's code alone pending that decision; happy to do the rebase once you and the maintainers pick a direction.

Review performed with AI assistance (Claude). Findings were verified by building and running the branch and by exercising the ffmpeg recipe against real media, not by reading alone.

Copy link
Copy Markdown
Contributor Author

Merge-order decision: #657 will land first. I’ve pushed its review fixes in 5cb55b9.

I’ll keep #659 separate until #657 is merged, then rebase #659 onto the updated main, address the four findings from this review, and consolidate the DV recipe into #659’s general RemuxFilterVersion / VideoBitstreamFilter contract. That rebase will deliberately produce one versioned remux-filter mechanism rather than preserving both dvrv and rfv, and I won’t use a mechanical conflict resolution across the overlapping files.

@zZebrahz zZebrahz removed the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Sep 19, 2026
blurbery and others added 2 commits October 2, 2026 16:46
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

silo-kody Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

@macroscopeapp

macroscopeapp Bot commented Oct 2, 2026

Copy link
Copy Markdown

The PR body is missing the required Validation tasks: line. I found no recorded playback result that needs retesting; please add:

Validation tasks: none

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@silo-kody

silo-kody Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

@blurbery

blurbery commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@Quick104 thanks for the review, and sorry it sat so long. #657 was closed, so the merge-order question went away, but main has since gained its own remux recipe plumbing and node-routed remux. Rather than force a second versioning scheme on top of that, I merged main taking its tree as is (e3eea2a) and rebuilt the fix on main's existing remux path.

The drop is now a best-effort flag (RemuxResumeLeadingPictureDrop). It's frozen into the session, the remux recipe card, the executable recipe and the stream token (rlpd), the same way RemuxDVMode travels. It isn't a plan transformation or a required capability. Against your findings:

  1. Rolling-upgrade capacity_unavailable. Gone. The drop never reaches plan.Transformations, so planRequiresServerTransformationsV3 and node-pool narrowing don't see it. An older node ignores the claim and serves the plain copy.
  2. Uncached probe that also ran at seek 0. The -h bsf=noise probe is cached per binary like the dovi_rpu one, and only runs when the filter would actually apply (seek past zero, video present). A start at zero never probes and can't fail on an FFmpeg without the filter.
  3. Filter copied onto transcode cards on reconstruct. There's no filter/version pair any more, only a bool that's read on the remux path alone, so there's nothing to pair wrongly.
  4. Local path re-deriving the codec from live rows. The codec decision happens once, at planning, and is frozen into the session. The executor never re-reads media_files for it.

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.

@Quick104
Quick104 merged commit a05c7c8 into Silo-Server:main Oct 7, 2026
13 checks passed
@blurbery
blurbery deleted the fix/issue-658-firefox-hevc-resume branch November 6, 2026 00:01
Quick104 added a commit that referenced this pull request Nov 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[bug] macOS Firefox fails HEVC progressive-remux resume at an open-GOP boundary

3 participants