You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(playback): try a remux of multi-PPS H.264 first and transcode only after it fails - #3475
Other clients: N/A (server-side change; the Apple, Android and web apps already ask for another plan when a video fails to play, so none needs a change; Roku not checked)
Some videos always got the expensive treatment. Some video files are built in an unusual way, and some players show a broken picture when they play them. In #424 the server started converting every such file into a new video before sending it. That conversion is called a transcode. It is heavy work for the server on every play, and the picture loses some quality.
Many players play these files fine. The Android apps and the iPad app do. Only some players break, like a web browser. So most viewers got a transcode they did not need whenever their app could not play the file exactly as it is on disk.
Now each player gets the cheap way first. The server copies the video into a format the player accepts, without changing the picture. That copy is called a remux. If the player says the remux failed, the server switches it to a transcode.
Approach
For a flagged file, the server tries these in order, skipping any the player already failed:
1. send the file as it is (direct play)
2. remux, progressive download (video copied, container or audio changed)
3. remux, HLS (video copied)
4. transcode (video converted)
New: once step 2 or 3 has failed for this file, the server skips the other remux and goes to 4.
Android TV, file it can open: 1 plays → nothing converted
Android, container it can't open: 2 plays (1 is not offered) → nothing converted
Web browser: 1 fails → 2 fails → 4 plays → step 3 is skipped
Before this change: steps 2 and 3 were never offered for a flagged file.
The apps already report a failed video and ask the server for another way, so no app needs an update.
Technical detail
The files are H.264 streams that redefine the same pic_parameter_set_id in-band with different content (multi-PPS). Decoders that apply in-band parameter sets, such as Media3 on Android, play a stream copy of them. Decoders that use only the sample entry's parameter sets, such as VideoToolbox and browser Media Source Extensions, fail on every copy delivery the same way.
refactor(playback): stop ending stream copies on the copy-safety verdict
The multi-PPS verdict no longer ends a copy that is playing or refuses to rebuild one. A copy that plays has shown that its decoder handles the source. A copy that fails reports it, and the recovery replan reads the persisted verdict.
Removes CopySafetyNotifier and its handler adapter. The scan verdict landing mid-play no longer sends plan_invalidated or stops the session.
Removes the refusals in playback_copy_safety.go and their call sites in the HLS serve path, the progressive remux serve path (stream.go) and the node rehome. A copy rebuilt after a replica restart, a node loss or a rehome is served like any other recipe.
CopySafetyRace now only scans and persists the verdict, deduped per file and capped at four concurrent scans. Its notify and recheck passes are gone.
The plan_invalidated_v1 protocol, its video_copy_unsafe reason and the client contract stay. No server path sends the command now. §6.1 of docs/architecture/playback-protocol-v3.md says so.
fix(playback): copy multi-PPS H.264 once before encoding it
routeFacts in internal/playback/candidate_video_v3.go no longer turns the remux routes off for source.VideoCopyUnsafe.
copyOnceEvaluator in the same file covers a copy-unsafe source. When a copy candidate's plan key is already in the replan's attempted keys, it skips every later copy candidate, so the next route is the encode (copy_routes_exhausted). Other sources try each copy delivery as before.
The attempted keys are the only state. Nothing new is stored, and there is no migration.
§6.1.1 of the protocol doc describes the rule.
Unchanged: jellycompat (it never read the verdict), the downloads policy (playback.Resolve still skips the copy), and the surround-conversion route (still skipped for these sources).
Validation
Go build, gofmt, go vet: clean.
golangci-lint v2.15.0 with --new-from-rev origin/main on the touched packages: 0 issues.
go test on internal/playback/..., internal/apiv2/..., internal/catalog/..., internal/scanner/... and internal/api: pass, with the real-FFmpeg tests run against jellyfin-ffmpeg 8.
go test on internal/api/handlers: three tests fail (TestCompleteDiagnosticChunksKeepsSessionOnRetryableFailure, TestInitDiagnosticChunksConcurrentInitsHoldOneSession, TestPluginUploadSeamsOnRealManager). They fail the same way on main on the test host and are unrelated to playback.
The first commit builds and passes the playback tests on its own.
A new planner test checks a flagged source going from a copy to the encode after one failed copy, while an out-of-date verdict still gets the second copy.
Not run: the web half of the full gate. No web files changed.
Evidence
Nothing changes on screen. The evidence page shows how three players played one of these files: an iPad played it as is, Chrome went from direct play to a copy to a transcode in about 4 seconds, and Android TV played it as is. Those captures come from this pull request's first implementation, which this rewrite replaces. For those three players the rewrite chooses the same routes, but it has not been tested on a device yet.
A player that breaks without saying so won't be caught. Some Android devices fall back to a built-in software decoder that shows a broken picture without reporting an error. The server never hears about it, so it never switches. Those devices were already at risk when they played the file as it is.
Some players see a short pause before the switch. A web browser fails twice before it gets the transcode, which took about 4 seconds in testing. Before this change it failed once.
Any failed remux counts, even one caused by the network. After that, the viewing goes to a transcode. That is still no worse than before this change.
The "remux failed" memory is short. Changing the quality, audio or subtitles makes the server try one remux again. A fresh viewing also starts over.
A failure before the file is scanned costs one more try. The scan runs in the background after the first play starts. If the player fails before the scan finishes, it tries both remux kinds before the transcode.
No database change.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
AI Disclosure
Harness: Claude Code
Tool(s): Claude Code
Model(s): claude-opus-5-5
Involvement: AI-assisted
Adversarial review: n/a for this rewrite. The branch was rebuilt from scratch on current main, and no independent review pass has run on it yet. The earlier implementation's Codex and maintainer reviews do not cover this code.
Note
Try remux of copy-unsafe multi-PPS H.264 before falling back to transcode
Copy-unsafe sources now get one stream-copy (remux) attempt per recovery. candidatePlannerV3.copyOnceEvaluator in candidate_video_v3.go allows one attempted remux plan, then skips further remux candidates; the next plan uses HLS transcode with reason copy_routes_exhausted.
Removes all runtime refusals of copy-unsafe playback: PlaybackHandler.loadTranscodeServeSession, moveTranscodeOffNodeV3, and StreamHandler.HandleStream no longer reject remuxes based on a persisted copy-safety verdict.
Removes the plan-invalidation notifier wiring: api.newChiRouter no longer supplies the session manager, plan store, or command dispatcher to the copy-safety race. The CopySafetyPlaybackControl adapter and the errRehomeCopyUnsafe sentinel are deleted.
Rewrites the copy-safety section of playback-protocol-v3.md; CommandPlanInvalidated and PlanInvalidatedVideoCopyUnsafe remain wire-contract values but no server path sends them.
Risk: routeFacts no longer disables remuxActive for VideoCopyUnsafe sources — check clients that relied on a copy-unsafe verdict immediately forcing transcode.
This changes visible playback behavior: clients now try a remux before falling back to a transcode after a decode failure. The Evidence section says “none,” so it does not show this multi-step flow. Suggested fix: attach a short recording of the affected client playing the same multi-PPS media through the failed remux and transcode fallback, and identify the client surface and build or commit used.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The v3 playback planner now tracks video-copy failures for an attempt. For multi-PPS sources, it can offer copy routes before a failure and exclude further copy routes during eligible recovery replans. The copy-safety notifier leaves a v3 copy in place until a copy failure is recorded.
Changes: V3 video-copy recovery
Layer / File(s)
Summary
Persist copy-failure state and select routes internal/playback/protocol_v3.go, internal/playback/plan_v3.go, internal/playback/executable_recipe_v3.go, internal/playback/protocol_v3_test.go, docs/architecture/playback-protocol-v3.md
The v3 request, planner result, and frozen recipe carry VideoCopyFailed. Copy-unsafe sources can use progressive or HLS remux until that marker is set; after a recorded failure, the planner skips those routes. Tests cover unresolved and stale copy-safety verdicts. The protocol documentation describes the updated recovery behavior.
Record failures during recovery internal/api/handlers/playback_v3.go, internal/api/handlers/playback_v3_test.go, internal/playback/copy_safety_notifier.go, internal/playback/copy_safety_notifier_test.go
Eligible recovery replans mark a failed video-copy route in the frozen recipe and pass the marker into planning. Proxy-origin, unreachable-node, and listed non-video-decode failures do not set it. The notifier leaves a v3 copy running until the marker is set. Tests cover the recovery route sequence and notifier behavior.
sequenceDiagram
participant Client
participant PlaybackV3Handler
participant FrozenRecipe
participant PlanPlaybackV3
Client->>PlaybackV3Handler: Send failure-recovery request
PlaybackV3Handler->>FrozenRecipe: Mark failed video copy when eligible
PlaybackV3Handler->>PlanPlaybackV3: Pass request with VideoCopyFailed
PlanPlaybackV3->>PlaybackV3Handler: Return selected recovery plan
Loading
Possibly related PRs
Silo-Server/silo-server#3033: Defines subtitle-route failures on copy remuxes, which this change excludes from setting VideoCopyFailed.
Silo-Server/silo-server#3331: Adds embedded-subtitle rendition failure handling, which this change excludes from setting VideoCopyFailed.
Suggested labels:api-v2
Suggested reviewers:quick104, rhainland
Merge Risk: Minimal · up to aaa19
The v3 recovery state and copy-route behavior are consistent with the intended contract; no merge-blocking risk remains.
Architecture risk: Low · up to aaa19
The change affects 2 systems.
Changed systems:internal, docs
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — internal (service) was modified; 8 changed files map to changed impact.
observed — docs (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
observed — Modified behavior in internal/playback/copy_safety_notifier.go: When a v3 attempt has a nonempty current-plan delivery and its frozen recipe does not report video-copy failure, consider now marks the session disposed without invalidating or stopping it; other cases continue to the existing handling.
observed — Modified behavior in internal/playback/copy_safety_notifier_test.go: remuxAttempt now sets FrozenRecipe.VideoCopyFailed to true; the added comments describe this fixture state.
observed — Modified behavior in internal/playback/copy_safety_notifier_test.go: Adds a test with two remux sessions: the attempt with VideoCopyFailed == false remains running, while the fixture attempt marked as failed is stopped.
observed — Modified behavior in internal/playback/executable_recipe_v3.go: ExecutableRecipeV3 adds the optional VideoCopyFailed field to record whether video stream-copy already failed on the client.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: multi-PPS H.264 sources now try a video-copy remux before falling back to a transcode, which matches the summary (planner allows copy until a copy failure is recorded,…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is detailed and directly related to the changeset. It covers the removal of CopySafetyNotifier and copy refusals, the copy-once-before-encoding rule for multi-PPS H.264 sources, the ne…
Full details: Title check
Explanation
The title names the main change: multi-PPS H.264 sources now try a video-copy remux before falling back to a transcode, which matches the summary (planner allows copy until a copy failure is recorded, then transcodes). It is specific and accurate, and it reads as a conventional feat(...) commit title.
Full details: Description check
Explanation
The description is detailed and directly related to the changeset. It covers the removal of CopySafetyNotifier and copy refusals, the copy-once-before-encoding rule for multi-PPS H.264 sources, the new VideoCopyFailed-style persisted mark, the protocol doc (section 6.1), validation runs, and risks. Its content matches the raw summary and PR objectives, so the check passes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 543353bd-5406-4563-8cc9-047d556019ce
Commits
Reviewing files that changed from the base of the PR and between 51c93f4 and aaa191d.
Files selected for processing: 2
docs/architecture/playback-protocol-v3.md
internal/api/handlers/playback_v3.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Output-change fallback drops the sticky copy failure
An output change that falls back to the playing edition can reoffer the failed multi-PPS remux and freeze the failure flag as false. Propagate start.VideoCopyFailed to currentEffectiveStart as well.
Prompt for LLM
File internal/api/handlers/playback_v3.go, line 6141:
Output-change fallback drops the sticky copy failure
The failed-copy flag is assigned after `currentEffectiveStart` is captured, so an output change that falls back to the playing edition in `planReplanV3` can reoffer the failed multi-PPS remux and freeze the flag as false. Propagate the flag to the fallback request snapshot as well.
Suggested code:
start.VideoCopyFailed = record.FrozenRecipe.VideoCopyFailed
currentEffectiveStart.VideoCopyFailed = start.VideoCopyFailed
The reason will be displayed to describe this comment to others. Learn more.
Confirmed and fixed in 51f5ee7. planReplanV3 now copies VideoCopyFailed from start into the fallback request, next to the bandwidth estimate it already inherits, so an output change that falls back to the playing edition still refuses the failed copy and keeps the mark frozen.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for confirming the fix in 51f5ee798. Propagating VideoCopyFailed to the fallback request addresses the reported issue: an output change falling back to the playing edition should no longer reoffer the failed copy.
The reason will be displayed to describe this comment to others. Learn more.
Newly permitted copies cannot be reconstructed after a restart
A restart or lost HLS runtime breaks playback because reconstruction still rejects the selected multi-PPS remux. Update the gates in stream.go and loadTranscodeServeSession to honor the attempt's failed-copy state.
Prompt for LLM
File internal/playback/plan_v3.go, line 646:
Newly permitted copies cannot be reconstructed after a restart
A multi-PPS remux selected here is still rejected by the existing reconstruction gates in `stream.go` and `loadTranscodeServeSession` once the verdict is known, so a restart or lost HLS runtime breaks playback even for clients that successfully decode the copy. Update those gates to honor the attempt's failed-copy state instead of rejecting every copy-unsafe source.
The reason will be displayed to describe this comment to others. Learn more.
Not changing this. It is the tradeoff listed under Risks. When a replica dies mid-copy, the unchanged revival gate refuses to rebuild a multi-PPS copy, and the client recovers with a fresh attempt. That attempt offers the copy again, so playback resumes on the copy; it does not break. Keeping the gates as they are means a reconstructed session never revives a copy without a fresh plan, and it keeps this change out of the token and recipe-card paths.
The reason will be displayed to describe this comment to others. Learn more.
Understood. I’ll withdraw the suggestion: the existing revival gate is an intentional tradeoff. After replica loss, the client recovers through a fresh attempt and may retry the copy, rather than reconstructing the previous session.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f52179a. The gates now let the rebuild through while the attempt has not recorded a failed copy. Before this PR, the gate only caught copies that had been planned before the verdict existed. With copy-first, every copy of a known multi-PPS file would hit it, so a replica restart or node loss ended a copy the client was playing, and the fresh attempt was offered the same copy again. Details are in the review thread on copy_safety_notifier.go.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. Allowing reconstruction while the attempt has no recorded copy failure addresses the concern I raised. I haven’t independently verified commit f52179a656.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 90bd830b-5f0b-43e7-9c53-d162854de5ab
Commits
Reviewing files that changed from the base of the PR and between 48a4b49 and 95e1566.
Files selected for processing: 9
docs/architecture/playback-protocol-v3.md
internal/api/handlers/playback_v3.go
internal/api/handlers/playback_v3_test.go
internal/playback/copy_safety_notifier.go
internal/playback/copy_safety_notifier_test.go
internal/playback/executable_recipe_v3.go
internal/playback/plan_v3.go
internal/playback/protocol_v3.go
internal/playback/protocol_v3_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 71408148-ea7b-4908-800a-533c7ae16d70
Commits
Reviewing files that changed from the base of the PR and between 95e1566 and 51f5ee7.
Files selected for processing: 3
docs/architecture/playback-protocol-v3.md
internal/api/handlers/playback_v3.go
internal/api/handlers/playback_v3_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The current Validation tasks: line covers only Movies/Server #197. This change is in the shared v3 planner and also reaches the Series playback cases on the server, web, Apple, and Android surfaces. Those Series cases are all Not run; the legacy Movies web/native playback tasks have no result rows either, so I found no passed, failed, or blocked result to invalidate or unblock. Please include the affected cross-surface tasks in the line.
The reason will be displayed to describe this comment to others. Learn more.
Browser video stalls are always classified as network failures
A decoded video stall can leave VideoCopyFailed unset, allowing an unsafe copy to be offered again instead of transcoding. Distinguish video stalls from confirmed network failures before exempting browser_engine_read_failed.
Prompt for LLM
File internal/api/handlers/playback_v3.go, line 6701:
Browser video stalls are always classified as network failures
The browser engine also emits `browser_engine_read_failed` when audio continues but decoded video stops arriving, so treating every such failure as a network error leaves `VideoCopyFailed` unset and can reoffer an unsafe copy instead of transcoding. Distinguish video stalls from confirmed network read failures before exempting this classification.
The reason will be displayed to describe this comment to others. Learn more.
Confirmed: EnginePlayer.ts sends ENGINE_READ_FAILED for "stopped receiving video" while audio keeps playing, which is how a strict decoder fails a copy. Fixed in aaa191d: browser_engine_read_failed is no longer in notVideoDecodeFailuresV3, so it marks the copy as failed like any unlisted classification. A real connection loss on the web now costs a transcode, which still plays.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for confirming. Removing browser_engine_read_failed from the exemptions addresses the reported issue: a browser video stall on a copy route can now mark the copy as failed and trigger a transcode.
The tradeoff is that a genuine browser connection failure reported under the same classification may also trigger an unnecessary transcode. I haven’t independently verified commit aaa191d1c or its tests.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 1c423963-5359-4da9-a551-b63d2dabba0f
Commits
Reviewing files that changed from the base of the PR and between 6f06901 and 51c93f4.
Files selected for processing: 3
docs/architecture/playback-protocol-v3.md
internal/api/handlers/playback_v3.go
internal/api/handlers/playback_v3_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
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 settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 4 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
Preserve durable media identity and share identity-evidence precedence
Bound decoder throughput trades and share direct-play eligibility
The reason will be displayed to describe this comment to others. Learn more.
Two findings on the head after I merged main in (e7000f8b26). Main had moved the planner into a candidate list (#3948), so that merge moved the copy-first gate to candidate_video_v3.go and ported the handler test to the v2 helpers.
Two stale texts outside the diff lines, which I'm also fixing: the VideoCopyUnsafe comment in internal/playback/protocol_v3.go still says copy routes are disqualified and a real encode is used, and §6.1 of docs/architecture/playback-protocol-v3.md still says "Three scoping rules" and describes a replan walking between copies as the failure case.
Reviewed head: f52179a (main merged in at e7000f8, then two fixes).
Fit: 7/10 · Readiness: 8/10 — conditional (assuming CI is green)
Fit. The change keeps these files off the transcoder for players whose decoders handle them (Media3 on Android). That saves a full encode per play, which matters most on low-end servers, and it adds no setting and needs no client update. It holds back from a higher score because the server learns per viewing, not per device: a strict decoder (Safari or Chrome on macOS, VideoToolbox) fails one copy at the start of every viewing before it gets the transcode. The PR's Risks section states this.
Readiness. The approach is sound, and the author showed the three routes live on iPad, Chrome and Android TV. The condition: the revival-gate fix below is proven by a handler test, not live, because no multi-PPS test file was available to restart a server under.
Addressed in this review
Revival gate refused planned copies (major). A replica restart, a request on another replica, or a node loss ended a copy the client was playing, and the fresh attempt got the same copy again. The gate now serves the rebuild until the attempt records a failed copy, the same rule as the notifier. A new handler test failed on e7000f8 and passes on f52179a.
Non-decoder reports marked the copy as failed (minor).sourceRefused and repeated viewer-change reports no longer set the mark. Checked by reading the code; no new test.
Stale text. The VideoCopyUnsafe comment and §6.1 of the protocol doc now describe copy-first and the revival rule.
The mark lasts one viewing, so strict decoders pay the failed copy every time (disclosed). A per-device signal would remove that cost; this PR doesn't need it to land.
During a mixed-version rollout, an older replica can drop the mark on a replan it plans (disclosed).
Other feedback
Kody's two open threads: the output-change fallback is fixed on the head (planReplanV3 copies the mark), and the reconstruction concern is now fixed as described above.
A Codex review round found one more candidate: web engine audio failures marking the copy. It doesn't apply, because the web engine only plays original_http plans and the mark needs a copy plan.
Tests
The PR's new tests don't build on main, because they read fields the PR adds, so they don't show the old behavior failing. The planner and handler tests pass on the head. Three handler tests and one real-FFmpeg test fail the same way on main on the review host (file permissions and FFmpeg 4.4).
Validated features
No passed case on the v1.0 board reaches this code. The behavior changes only for files flagged multi-PPS, and no validated case uses one. The Validation tasks: line is still accurate; none of those tasks has a result yet.
User manual and clients
Manual unaffected: no siloserver.org page describes how these files are delivered.
No client change: the Apple, Android and web apps already replan within a viewing on a decode error. Roku wasn't checked. jellycompat is unchanged.
The published evidence still matches the head: the fixes don't change the three routes it shows.
🤖 Claude Code (claude-opus-5-5)
silo-triageBot
added
size/XL
500–999 added + deleted lines (all files); change volume, not priority.
and removed
size/L
200–499 added + deleted lines (all files); change volume, not priority.
labels
Nov 16, 2026
Everything under "Addressed in this review" is on the branch, and the head is now 39467b6.
Since that review:
Merged main again; the conflict with main is gone and the PR is mergeable.
A plan-store read error no longer stops a copy that is playing or refuses its rebuild. Both now act only when the attempt is confirmed missing or has recorded a failed copy. A new notifier test covers the stop.
The mark is logged the first time it is set, with the failed delivery and the classification.
The revival test signs its node relay, which main now requires.
CI is green on the head, including Go DB pins. The two items left for the maintainers are unchanged: the mark lasts one viewing, and an older replica can drop it during a mixed-version rollout.
The H.264 multi-PPS verdict no longer withdraws a copy that is playing or
refuses to rebuild one. A copy that plays has shown its decoder handles the
source; one that fails reports it, and the recovery replan plans against the
persisted verdict.
Removes CopySafetyNotifier and its handler adapter, the race's notify and
recheck passes, and the revival, reconstruct and rehome refusals. The race now
only scans and persists. The plan_invalidated protocol stays, with no producer.
A source flagged multi-PPS used to skip every video stream-copy route, so a
client that could not direct-play it always got a full transcode, even when
its decoder (Media3 on Android) plays a copy cleanly.
The planner now offers such a source the copy like any other. When a recovery
replan's attempted keys already hold one of its copy plans, the other copy
delivery is skipped and the next route is the encode, so a strict decoder
(VideoToolbox, browser MSE) costs at most two failed routes. The attempted
keys are the only state; no new field is stored.
The reason will be displayed to describe this comment to others. Learn more.
Surround-bitstream copy failures do not exhaust copy routes
A copy-unsafe source can reach another video-copy remux and fail decoding again because copyFailed remains unset. Include candidateSurroundBitstreamV3 in the attempted-copy check before evaluating subsequent remux candidates.
Prompt for LLM
File internal/playback/candidate_video_v3.go, lines 345-346:
Surround-bitstream copy failures do not exhaust copy routes
A failed surround-bitstream HLS remux does not set `copyFailed`, so a copy-unsafe source falls through to another video-copy remux instead of the encode and can fail decoding a second time. Include `candidateSurroundBitstreamV3` in the attempted-copy check before evaluating subsequent remux candidates.
The reason will be displayed to describe this comment to others. Learn more.
A scan request for a replacement file is lost behind a stale scan
A replacement file can remain unscanned when the previous scan returns stale without persisting a verdict. Retain a pending recheck when r.inFlight already contains fileID, and run it after the scan completes.
Prompt for LLM
File internal/playback/copy_safety_race.go, lines 103-105:
A scan request for a replacement file is lost behind a stale scan
A request for a rewritten file is dropped if the previous generation's scan is still in flight; that scan then returns `stale` without persisting a verdict, leaving the replacement unscanned until another request happens. Retain a pending recheck and run it after the in-flight scan completes.
Closing in favor of #5144. The candidate-list planner (#3948) already skips every route a player has failed, so the copy-once rule this PR added isn't needed. #5144 drops the remux gate from #424 and leaves the rest to the normal recovery walk. It also removes the mid-play copy withdrawal, which the maintainer review found ending copies that were playing fine. The mid-scan rescan Kody raised here is fixed there too.
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
api-v2API v2 / Huma migration program (epic #135); long-running, stacked by phaseenhancementNew feature or requestevidence-requiredNeeds before-and-after evidence before the Evidence check passesgoPull requests that update go codeimpact: playbackCan't play, stalls, or wrong mediapriority: P2Limited scope, workaround exists, or polishsize/XXL1000–2999 added + deleted lines (all files); change volume, not priority.
2 participants
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.
Two commits. The first removes code that ends these streams early, and the second lets the server try the cheap way first.
Problem
Related issue: N/A
Validation tasks: changes #197 (Movies/Server playback criterion "remux/transcode fallback"), #199, Silo-Server/silo-apple#22, Silo-Server/silo-apple#23, Silo-Server/silo-android#7, Silo-Server/silo-android#8 (Movies playback); changes #1250 C5, #1252 C3, Silo-Server/silo-apple#337 C3, Silo-Server/silo-apple#338 C3, Silo-Server/silo-android#347 C3, Silo-Server/silo-android#348 C3 (Series playback). None has a recorded result yet.
Other clients: N/A (server-side change; the Apple, Android and web apps already ask for another plan when a video fails to play, so none needs a change; Roku not checked)
Some videos always got the expensive treatment. Some video files are built in an unusual way, and some players show a broken picture when they play them. In #424 the server started converting every such file into a new video before sending it. That conversion is called a transcode. It is heavy work for the server on every play, and the picture loses some quality.
Many players play these files fine. The Android apps and the iPad app do. Only some players break, like a web browser. So most viewers got a transcode they did not need whenever their app could not play the file exactly as it is on disk.
Now each player gets the cheap way first. The server copies the video into a format the player accepts, without changing the picture. That copy is called a remux. If the player says the remux failed, the server switches it to a transcode.
Approach
The apps already report a failed video and ask the server for another way, so no app needs an update.
Technical detail
The files are H.264 streams that redefine the same
pic_parameter_set_idin-band with different content (multi-PPS). Decoders that apply in-band parameter sets, such as Media3 on Android, play a stream copy of them. Decoders that use only the sample entry's parameter sets, such as VideoToolbox and browser Media Source Extensions, fail on every copy delivery the same way.refactor(playback): stop ending stream copies on the copy-safety verdict
The multi-PPS verdict no longer ends a copy that is playing or refuses to rebuild one. A copy that plays has shown that its decoder handles the source. A copy that fails reports it, and the recovery replan reads the persisted verdict.
CopySafetyNotifierand its handler adapter. The scan verdict landing mid-play no longer sendsplan_invalidatedor stops the session.playback_copy_safety.goand their call sites in the HLS serve path, the progressive remux serve path (stream.go) and the node rehome. A copy rebuilt after a replica restart, a node loss or a rehome is served like any other recipe.CopySafetyRacenow only scans and persists the verdict, deduped per file and capped at four concurrent scans. Its notify and recheck passes are gone.plan_invalidated_v1protocol, itsvideo_copy_unsafereason and the client contract stay. No server path sends the command now. §6.1 ofdocs/architecture/playback-protocol-v3.mdsays so.fix(playback): copy multi-PPS H.264 once before encoding it
routeFactsininternal/playback/candidate_video_v3.gono longer turns the remux routes off forsource.VideoCopyUnsafe.copyOnceEvaluatorin the same file covers a copy-unsafe source. When a copy candidate's plan key is already in the replan's attempted keys, it skips every later copy candidate, so the next route is the encode (copy_routes_exhausted). Other sources try each copy delivery as before.playback.Resolvestill skips the copy), and the surround-conversion route (still skipped for these sources).Validation
gofmt,go vet: clean.--new-from-rev origin/mainon the touched packages: 0 issues.go testoninternal/playback/...,internal/apiv2/...,internal/catalog/...,internal/scanner/...andinternal/api: pass, with the real-FFmpeg tests run against jellyfin-ffmpeg 8.go testoninternal/api/handlers: three tests fail (TestCompleteDiagnosticChunksKeepsSessionOnRetryableFailure,TestInitDiagnosticChunksConcurrentInitsHoldOneSession,TestPluginUploadSeamsOnRealManager). They fail the same way onmainon the test host and are unrelated to playback.Evidence
Nothing changes on screen. The evidence page shows how three players played one of these files: an iPad played it as is, Chrome went from direct play to a copy to a transcode in about 4 seconds, and Android TV played it as is. Those captures come from this pull request's first implementation, which this rewrite replaces. For those three players the rewrite chooses the same routes, but it has not been tested on a device yet.
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3475/
Risks
Checklist
AI Disclosure
main, and no independent review pass has run on it yet. The earlier implementation's Codex and maintainer reviews do not cover this code.Note
Try remux of copy-unsafe multi-PPS H.264 before falling back to transcode
candidatePlannerV3.copyOnceEvaluatorin candidate_video_v3.go allows one attempted remux plan, then skips further remux candidates; the next plan uses HLS transcode with reasoncopy_routes_exhausted.PlaybackHandler.loadTranscodeServeSession,moveTranscodeOffNodeV3, andStreamHandler.HandleStreamno longer reject remuxes based on a persisted copy-safety verdict.api.newChiRouterno longer supplies the session manager, plan store, or command dispatcher to the copy-safety race. TheCopySafetyPlaybackControladapter and theerrRehomeCopyUnsafesentinel are deleted.CommandPlanInvalidatedandPlanInvalidatedVideoCopyUnsaferemain wire-contract values but no server path sends them.routeFactsno longer disablesremuxActiveforVideoCopyUnsafesources — check clients that relied on a copy-unsafe verdict immediately forcing transcode.Macroscope summarized df4a4f9.