Skip to content

fix(playback): stop reporting encode targets for copy sessions rebuilt after a restart - #3982

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/3100-copy-targets-after-restart
Nov 12, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/3100-copy-targets-after-restart

Conversation

@Rhainland

@Rhainland Rhainland commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #3100
Related issue: N/A
Validation tasks: touches #1206 C1 and #1207 C1 (both not yet run)

When the server restarts during a Jellyfin-client HLS remux, the admin sessions view starts reporting encode targets for a stream that only copies video. On a local build, a 1080p H.264 file remuxed under a 4 Mbps client limit showed no target before the restart. After the restart and the next segment request, it showed target_resolution: "720p". ffmpeg never applies that resolution to a copy.

The recipe card keeps the negotiated resolution and bitrate because jellycompat uses them to match and rebuild the negotiated stream. When reconstructSession rebuilt the session after a restart, it copied those card values onto the session even when the video is copied. This change leaves the card as it is and clears the two targets on the rebuilt session whenever the card copies video.

Approach

The fix sits at the shared rebuild in internal/playback, so native and jellycompat copy sessions follow the same rule. It reuses the existing RecipeCard.VideoStreamCopy() check, which covers progressive remux and HLS video copy. Encode sessions keep their targets.

Native /api/v2 HLS remux sessions change too. They used to report the source's own height label as target_resolution (for example "1080p") while live, and a rebuilt session also reported the card's bitrate. Clearing only the rebuilt session would have made the field change partway through a stream, so v3SessionStreamState now drops target_resolution whenever the session copies video. A native copy session reports no target resolution or target bitrate, live or rebuilt, which matches the v2 schema ("Empty when not transcoding"). The web admin view shows a remux as copied, using the source fields, and stream_bitrate_kbps falls back to the source bitrate. The one visible difference is the detail line for a version the server switched to automatically, which no longer repeats the output height for a copy. The Apple and Android clients do not read target_resolution.

Validation

  • Focused test at the rebuild seam: a copy card rebuilds with no targets, and an encode card keeps them. It failed on main and passes here.
  • go build ./..., gofmt, go mod tidy -diff, go vet ./..., make lint-changed and make lint-router-recovery: clean.
  • make test-go: passes. Four packages that do not touch this change (api/handlers, backup, ebookconvert, uploads) failed locally only because of a group-writable umask in the test shell, and they pass with umask 022.
  • make verify-playback-fixtures, verify-local-paths, verify-case-collisions, verify-bidi and verify-size-ratchet: pass. The web half and the API contract checks were not run because nothing in those areas changed.
  • Native live path: the extended TestV3SessionOutputFormatMatchesDelivery failed on the first commit of this branch for the three copy cases and passes now. On an isolated sandbox at 656f78c, a native HLS remux of a 1080p H.264 MKV reported target_resolution: null before and after a restart, and a native 720p encode kept "720p". Evidence: https://evidence.siloserver.org/r/silo-server/pr-3982-r2/
  • Local build with Postgres, Redis and a synthetic 1080p H.264 MKV. For each case: start playback, fetch four segments, restart the server, fetch the next two segments, then read /api/v2/admin/sessions once the rebuilt session has synced. Cases: Jellyfin HLS remux, Jellyfin HLS encode, and native /api/v2 HLS remux, each on main and on this branch.

Evidence

GET /api/v2/admin/sessions, trimmed to the stream fields. Source: 1080p, 3099 kbps.

Jellyfin HLS remux (4 Mbps client limit)
  main,   before restart: target_video_codec=copy target_resolution=null   target_bitrate_kbps=null stream_bitrate_kbps=3099
  main,   after restart:  target_video_codec=copy target_resolution="720p" target_bitrate_kbps=3099 stream_bitrate_kbps=3099
  branch, before restart: target_video_codec=copy target_resolution=null   target_bitrate_kbps=null stream_bitrate_kbps=3099
  branch, after restart:  target_video_codec=copy target_resolution=null   target_bitrate_kbps=null stream_bitrate_kbps=3099

Jellyfin HLS encode (1.5 Mbps client limit), branch
  before restart: target_video_codec=h264 target_resolution="540p" target_bitrate_kbps=1233
  after restart:  target_video_codec=h264 target_resolution="540p" target_bitrate_kbps=1233

Native /api/v2 HLS remux
  main,   before restart: target_resolution="1080p" target_bitrate_kbps=null stream_bitrate_kbps=3099
  main,   after restart:  target_resolution="1080p" target_bitrate_kbps=3099 stream_bitrate_kbps=3099
  branch, after restart:  target_resolution=null    target_bitrate_kbps=null stream_bitrate_kbps=3099

Surface and build: native admin API, main at 48748d9 and this branch.

Risks

The only change is to what copy sessions report to the admin views. The recipe card, stream matching and the rebuilt ffmpeg command stay the same. A native HLS remux's target_resolution now reads null, live and after a restart, instead of the source's label. No first-party client displays that field for a remux.

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 says there is none.

AI Disclosure

  • Harness: Claude Code (via T3 Code); Codex CLI for code review
  • Tool(s): Claude Code, Codex CLI
  • Model(s): claude-opus-5-5; gpt-6.1-sol (code review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: two independent reviews of the full branch diff, one by claude-opus-5-5 and one by gpt-6.1-sol, covering correctness, repo standards and the issue's spec. GPT found nothing. Opus found three low-severity points. A test assertion could never fail because the card is passed by value; it was removed. The other two concerned the native target_resolution change after a restart; both reviewers judged it display-only, and it is described above.

Note

Fix TranscodeManager.reconstructSession to drop encode targets for copy sessions after restart

After a restart, sessions rebuilt from a recipe card could report a target resolution and bitrate even when the card uses video stream copy. reconstructSession in transcode_manager.go now clears both targets for copy cards; non-copy cards keep their targets. Adds a table-driven test, TestReconstructSessionReportsOnlyAppliedVideoTargets.

Macroscope summarized 18bd676.

… restart

A recipe card keeps the negotiated target resolution and bitrate so the
stream can be matched and rebuilt, but a video copy applies neither.
reconstructSession copied them onto the session anyway, so after a server
restart the admin views showed encode targets for a remux that the live
session had never reported.

Closes Silo-Server#3100
@silo-kody

silo-kody Bot commented Nov 11, 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 ❌

@silo-triage silo-triage Bot added the size/S 0–49 added + deleted lines (all files); change volume, not priority. label Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Session reconstruction now clears target resolution and bitrate for video-copy cards. A test checks that reconstructed copy sessions have no targets and encoded sessions retain the card’s configured targets.

Changes: Playback session reconstruction

Layer / File(s) Summary
Reconstructed video targets
internal/playback/transcode_manager.go, internal/playback/transcode_manager_test.go
When a recipe card represents video copy, reconstruction clears the session’s target resolution and bitrate. The test checks this behavior and verifies that encoded video retains its configured targets.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested labels: bug, go, impact: playback, size/M

Suggested reviewers: quick104

Merge Risk: Minimal · up to 18bd6

Rebuilt video-copy sessions after a restart will no longer report encode targets, and encoded sessions keep theirs. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preventing encode targets from being reported for rebuilt copy sessions.
Linked Issues check Passed Issue #3100 requires rebuilt Jellyfin-compatible HLS copy sessions to report no encode targets after restart. The change clears TargetResolution and TargetBitrateKbps in reconstructSession when …
Out of Scope Changes check Passed The changes are limited to the shared playback rebuild rule and its focused test. The shared rule supports the #3100 copy-session fix for Jellyfin-compatible playback. The reported native HLS remux be…
Description check Passed The description is directly related to the changeset. It explains the problem (post-restart HLS copy sessions reporting encode targets), the fix in the shared reconstructSession rebuild path that clea…
Full details: Linked Issues check

Explanation

Issue #3100 requires rebuilt Jellyfin-compatible HLS copy sessions to report no encode targets after restart. The change clears TargetResolution and TargetBitrateKbps in reconstructSession when RecipeCard.VideoStreamCopy() is true. The focused test verifies that copy cards clear both values and encode cards retain them. The PR evidence also reports that the admin view continues to show source resolution and bitrate.

Full details: Out of Scope Changes check

Explanation

The changes are limited to the shared playback rebuild rule and its focused test. The shared rule supports the #3100 copy-session fix for Jellyfin-compatible playback. The reported native HLS remux behavior is a documented consequence of using this shared path, not an unrelated feature change. Encode sessions retain their targets.

Full details: Description check

Explanation

The description is directly related to the changeset. It explains the problem (post-restart HLS copy sessions reporting encode targets), the fix in the shared reconstructSession rebuild path that clears TargetResolution and TargetBitrateKbps for video-copy recipe cards, the related v3SessionStreamState change for native HLS remux sessions, the validation performed, and the risks. It is detailed and specific, so it passes the lenient check.

Finishing Touches

Generate unit tests (beta)

  • 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: 0f7e0035-4f0b-49a5-b17a-da6c4c3040e0
Commits

Reviewing files that changed from the base of the PR and between a9c7580 and 18bd676.

Files selected for processing: 2

  • internal/playback/transcode_manager.go
  • internal/playback/transcode_manager_test.go

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

@coderabbitai coderabbitai Bot added bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Nov 11, 2026
@silo-triage silo-triage Bot removed the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 11, 2026
…sion

A native HLS remux reported the source's height label as target_resolution
while live, and none once rebuilt after a restart, so the field changed on
a restart. The v2 contract documents it as empty when not transcoding.
Drop it whenever the session copies video.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 18bd676. One finding, inline below. I'm fixing it on this branch, and a summary comment follows.

Posted by Claude Code (claude-opus-5-5) for the maintainer.

Comment thread internal/playback/transcode_manager.go Resolved
@silo-triage silo-triage Bot added size/M 50–199 added + deleted lines (all files); change volume, not priority. and removed size/S 0–49 added + deleted lines (all files); change volume, not priority. labels Nov 12, 2026
@silo-kody

silo-kody Bot commented Nov 12, 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 ❌

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 656f78c (the PR's 18bd676 plus one review fix).

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

The fix is small and sits at the shared rebuild step. It reuses RecipeCard.VideoStreamCopy(), and a copy session now reports to the admin views what ffmpeg actually does. Nothing else reads the cleared fields to make a decision. After a restart, jellycompat stream matching and the rebuilt ffmpeg command read the recipe card, not the session. The web admin view reads target_resolution only for transcodes. The Jellyfin /Sessions surface doesn't expose these fields.

Addressed

  • Native remux target_resolution changed on a restart (low). The rebuild cleared the field, but a live native HLS remux still reported the source label, so the value dropped partway through a stream. Fixed in 656f78c: v3SessionStreamState drops target_resolution whenever video is copied, which matches the v2 schema ("Empty when not transcoding"). Verified live on an isolated sandbox: the native remux reports null before and after a restart, and a native 720p encode keeps "720p".

Tests

  • TestReconstructSessionReportsOnlyAppliedVideoTargets fails on the base (targets = ("720p", 3608), want ("", 0)) and passes on this branch.
  • The extended TestV3SessionOutputFormatMatchesDelivery fails on 18bd676 for the three copy cases and passes with the fix.

Left for the maintainers

  • Validation tasks: reads touches #1206 C1 and #1207 C1 (both not yet run), which isn't one of the forms in CONTRIBUTING.md. The validation board couldn't be read during this review. If those cases are still unrun, the line should be Validation tasks: none. Neither case can regress, because the change only makes a copy session's admin fields the same before and after a restart.

Checks

Evidence for the review fix: https://evidence.siloserver.org/r/silo-server/pr-3982-r2/

Posted by Claude Code (claude-opus-5-5) for the maintainer. A cross-provider review (gpt-6.1-sol) of 18bd676 found no further issues.

@Quick104
Quick104 merged commit 15a3578 into Silo-Server:main Nov 12, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Admin activity shows encode targets for a Jellyfin remux after a server restart

2 participants