Skip to content

fix(jellycompat): report the actual transcode target resolution/bitrate to admin sessions - #921

Merged
Quick104 merged 7 commits into
Silo-Server:mainfrom
rangoDJ:fix/jellycompat-transcode-target-telemetry-920
Oct 26, 2026
Merged

Quick104 merged 7 commits into
Silo-Server:mainfrom
rangoDJ:fix/jellycompat-transcode-target-telemetry-920

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The admin activity view can show the source resolution and bitrate for a Jellyfin-compatible transcode even when the encoder produces a smaller stream. This change reports the encoder's target values. Streams that copy video keep showing the source's values.

Closes #920
Related issue: N/A
Validation tasks: none (no passed case is affected; #1206 C1 and #1207 C1 cover the admin session details this changes and are Not run)

Approach

Record the effective transcode targets through the existing session telemetry path for local, reconstructed and remote playback. When video is copied, leave the unused encoder targets out of telemetry. The negotiated recipe keeps them for fallback and reconstruction.

Validation

  • TestRecordTranscodeStreamDetailsTargets drives the real session manager with an encode, a copy with copied audio, and a copy with encoded audio. Every row fails on current main and passes on this head. The jellycompat, playback, admin handler and reconciler package tests pass after merging current main, except TestCopyRemuxSubtitleRenditionRealFFmpeg, which fails the same way on untouched main with the local FFmpeg. Changed-line lint reports zero issues.
  • Every start path records what FFmpeg runs with. The local start records the running session's options after auto-pipeline and tone-map fallbacks. The remote start records the request it dispatched, after the VideoToolbox bitrate and software-retry adjustments. Each new start, including a fallback to another node or to local, overwrites the earlier targets.
  • On an isolated sandbox built from ecca6cf0, the same copied H.264/AAC stream changed from a reported 18.808 Mbps to its 2.610 Mbps source bitrate. Desktop and mobile web captures confirm the displayed correction; manifests and media segments still load. Later commits only merge main and change tests and a comment, so the sandbox was not rebuilt.
  • A real video encode still reports 480p with a 758 kbps ceiling. FFmpeg uses that ceiling, and a produced segment probes as H.264 at 854 × 480.
  • Remote-node execution was not exercised live.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-921/

Risks

Encoding, routing and API schemas are unchanged. Apple and Android need no matching change. The user manual already describes comparing source and delivered media, so no manual update is needed.

After an API server restart, a session that copies video is rebuilt from its recipe card and shows the negotiated targets again. That happens on main too; #3100 tracks it.

Checklist

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

AI Disclosure

  • Harness: Codex and Claude Code for review and the bounded fixes. The original author reported Claude assistance.
  • Tools: Codex read-only review agents, Claude Code read-only review subagents, Claude advisor, and Codex CLI.
  • Models: gpt-6.1-sol at xhigh effort; claude-opus-5-5 at high effort. The original author did not specify the Claude model.
  • Involvement: AI-assisted; verified with tests and an isolated sandbox.
  • Adversarial review: the first review (six read-only roles plus one cross-provider round) found a copy-stream telemetry regression, fixed in b7e777c1. A second review on 2366605f (three read-only finders, a validation check, and one cross-provider round that saw only the diff) found no defect in the change. It led to a test consolidation and a comment fix in 6af23438, and to [bug] Admin activity shows encode targets for a Jellyfin remux after a server restart #3100 for the restart case above.

Note

Report actual transcode target resolution and bitrate to admin sessions

  • playback.SessionManager.SetTranscodeStreamDetails now accepts and persists target resolution and target bitrate alongside the existing codec, audio, hardware, and tone-map decisions in session.go
  • jellycompat.PlaybackHandler.recordTranscodeStreamDetails in handlers_playback.go derives both values from the transcode options and forwards them to the session manager
  • For video-copy streams, the handler clears the video-only resolution and bitrate targets before recording, while keeping codec and audio decisions
  • Adds regression tests for both the recorded-values and copy-target clearing paths
  • Behavioral Change: SetTranscodeStreamDetails gains two required arguments; all implementers and test fakes must be updated

Macroscope summarized 2366605.

…te to admin sessions

SetTranscodeStreamDetails recorded the encode's video/audio codec, hw
accel, and tone-map mode on the upstream session, but never its
TargetResolution or TargetBitrateKbps. Only the native (non-compat)
playback path threaded those through directly. The admin sessions view
falls back to displaying the source's own resolution/bitrate whenever
target_resolution is unset for a transcoding session, so every
jellycompat-driven transcode — including a MaxStreamingBitrate-capped
downscale from Silo-Server#912 — showed as if it were streaming the source
unmodified, even though the real ffmpeg process was correctly capped.

recordTranscodeStreamDetails now forwards opts.TargetResolution and
opts.TargetBitrateKbps through the extended setter, so session sync and
the admin activity views reflect what ffmpeg is actually doing.

Fixes Silo-Server#920.
@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

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: bf2533ab-a477-4024-a9be-0c5e80e80a92
Commits

Reviewing files that changed from the base of the PR and between 2366605 and 6af2343.

Files selected for processing: 4
  • internal/jellycompat/audio_selection_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/remote_transcode_reconstruct_test.go
  • internal/playback/session.go

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

Walkthrough

Session recording now stores target resolution and bitrate. Jellycompat playback forwards the encode targets and clears them when video is copied.

Changes: Transcode Target Recording

Layer / File(s) Summary
Extend session recording
internal/playback/session.go, internal/jellycompat/handlers_playback.go, internal/jellycompat/audio_selection_test.go, internal/jellycompat/remote_transcode_reconstruct_test.go
The session recording method and Jellycompat setter interfaces accept target resolution and bitrate. Session managers store both values.
Forward Jellycompat targets
internal/jellycompat/handlers_playback.go, internal/jellycompat/audio_selection_test.go
Jellycompat playback forwards the targets and clears both values for copied video. Tests check recorded targets and retained codec and audio-transcode details.

Priority: Low

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

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

Suggested reviewers: quick104

Merge Risk: Minimal · up to 6af23

Encoded playback targets are recorded for admin sessions, while copied video omits unused encoder targets. No actionable merge-blocking risk is established.

Security architecture risk: Minimal · up to 6af23

The change corrects playback activity metadata without changing encoder authority, access checks, or playback routing. The inspected changes introduce no material security risk. Existing failure windows can leave stale activity metadata, but no security-control impact was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The introduced effect is bounded to target metadata on existing playback sessions and its existing synchronized admin representation. The complete production delta does not add a network route, session identity, execution destination, credential, or authorization decision.

Trust Boundaries and Controls

  • observed — In the inspected segment-recovery entry path, the handler requires an authenticated compatibility session, matches the playback session's token, requires an upstream session ID, and validates the selected route before invoking recipe preparation that can reach transcode recording. These checks are unchanged by the PR.

Resilience and Maintainability Implications

  • observed — Local telemetry publication precedes durable recipe persistence. If persistence fails, the code closes the exact transcode runtime and returns an error; the inspected segment caller returns the error without explicitly reverting telemetry. This ordering predates the PR, and the new fields inherit its possible stale-display window. Runtime cleanup remains ownership-scoped rather than closing a concurrent successor.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: the jellycompat transcode path now reports the actual encoder target resolution and bitrate to admin sessions. It matches the changeset, which threads target resolutio…
Description check Passed The description states the problem (admin activity view shows source resolution and bitrate for Jellyfin-compatible transcodes), the approach (record effective transcode targets through existing sessi…
Linked Issues check Passed Issue #920 requires Jellyfin-compatible transcode sessions to report the effective encode target resolution and bitrate to the admin sessions view. The whole-PR diff shows this behavior. In `internal/…
Out of Scope Changes check Passed All changed areas connect to #920. The SetTranscodeStreamDetails signature change adds two arguments for target resolution and bitrate. This is required for the telemetry path the issue requests. Th…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files.
Full details: Title check

Explanation

The title names the main change: the jellycompat transcode path now reports the actual encoder target resolution and bitrate to admin sessions. It matches the changeset, which threads target resolution and bitrate through SetTranscodeStreamDetails and recordTranscodeStreamDetails and clears them for video-copy streams. The title is 89 characters, slightly long, but it is specific and descriptive.

Full details: Description check

Explanation

The description states the problem (admin activity view shows source resolution and bitrate for Jellyfin-compatible transcodes), the approach (record effective transcode targets through existing session telemetry, omit encoder targets for video-copy streams), validation, risks, and a linked issue. It relates directly to the changeset.

Full details: Linked Issues check

Explanation

Issue #920 requires Jellyfin-compatible transcode sessions to report the effective encode target resolution and bitrate to the admin sessions view. The whole-PR diff shows this behavior. In internal/jellycompat/handlers_playback.go, recordTranscodeStreamDetails reads opts.TargetResolution and opts.TargetBitrateKbps and passes them to SetTranscodeStreamDetails. In internal/playback/session.go, SetTranscodeStreamDetails stores them in s.TargetResolution and s.TargetBitrateKbps. For video copy (opts.TargetCodecVideo == compatCopyCodec), the handler clears both values before recording, so the admin view falls back to source values for copied video. The incremental change since the previous reviewed head (2366605f) is comment-only in the changed source files, plus a test consolidation that was not read in this pass. The previous PASS conclusion for the implementation remains supported. The incremental diff tool output was unavailable (diff metadata exceeded the inspection buffer), so the test consolidation is not directly verified here. The PR author reports that the consolidated tests pass and the TestRecordTranscodeStreamDetailsTargets cases fail on main and pass on this head. The remote-node path was not exercised live, so the remote behavior relies on code and the reported start-path changes.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to #920. The SetTranscodeStreamDetails signature change adds two arguments for target resolution and bitrate. This is required for the telemetry path the issue requests. The recordTranscodeStreamDetails change forwards those values and clears them for copied video. The session manager change stores the values. The test fake and regression test updates support the changed interface and the new behavior. The comment edits in handlers_playback.go and session.go describe the new telemetry. The PR description reports no encoding, routing, or API schema change, and the whole-PR diffs of the core files show no unrelated logic. The test consolidation in 6af23438 was not read directly, because the incremental diff could not be retrieved. This does not change the verdict, because the consolidated tests cover the same #920 behavior according to the PR summary.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@rangoDJ

rangoDJ commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

All checks pass. Live verification: main alone has no code path that sets a non-empty TargetResolution/TargetBitrateKbps for jellycompat's local transcode start (only the VideoToolbox tone-map path does, which isn't reachable on this Linux/QSV test host), so there was nothing capped to report without #912. I deployed a temporary branch combining this fix with #912 to a real server + Jellyfin Android client, capped a stream to 420 kbps, and confirmed the admin sessions API now correctly reports target_resolution: "480p", target_bitrate_kbps: 420 — matching the real ffmpeg command — instead of falling back to the source's 1080p/uncapped values.

Also worth noting from that same testing session: selecting different quality tiers in the Jellyfin Android app and comparing the resulting dashboard resolution against Jellyfin's own canonical bitrate→resolution table (jellyfin-web's qualityOptions.js) showed the dashboard is reporting correctly per Jellyfin's own reference semantics in every case checked (e.g. 8 Mbps → 1080p, 3 Mbps → 720p, 720 kbps → 480p) — the Android app's on-screen quality labels just don't match Jellyfin's own internal maxHeight for those same bitrate values. That's a labeling quirk in the Jellyfin Android client, not something actionable here.

Keeps this branch's target resolution and bitrate arguments and main's
EffectiveEncoderHWAccel() in the compat transcode details call.

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

kody-ai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Unexpected error while running the code review (openai_compatible).

openai_compatible · muse-spark-1.3-contributor · HTTP 400 · generalist

Provider said: Model does not support this protocol.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

​

@macroscopeapp

macroscopeapp Bot commented Sep 28, 2026

Copy link
Copy Markdown

The PR body is missing the required Validation tasks: line. The relevant records in #1207 C1 (Web admin) and #1246 C1–C3 (Jellyfin compatibility) are all Not run, so there are no recorded results to list. Please add:

Validation tasks: none

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

Posted via Macroscope — v1 validation impact

@rangoDJ

rangoDJ commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@kody review

@kody-ai

kody-ai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

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

Reviewed 603b3b15fd625df555606ac8dbd0cdb8ed457b17. One verified telemetry regression is described inline; I am applying the bounded fix. Independent read-only review by GPT-6.1 Sol and Claude Opus 5.5 reached the same finding.

AI disclosure: Codex (gpt-6.1-sol); independent review through Claude advisor (claude-opus-5-5, high effort).

@silo-kody

silo-kody Bot commented Oct 13, 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

Quick104 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed 2366605f; fixes pushed in 6af23438. This head merges current main (3f486c92) without conflicts.

The change still does what it says on current main. Every jellycompat start path records the options FFmpeg actually runs with. The local start records the running session's options after the auto-pipeline and tone-map fallbacks. The local rebuild from the compat store records the rebuilt session's options. The remote start records the request it dispatched, after the VideoToolbox bitrate and software-retry adjustments. A new start, including a fallback to another node or to local, overwrites the earlier targets, and a remote start that loses to a local one leaves the local start's values in place. The merges since the last review changed none of these paths.

Addressed in 6af23438: the fake-backed forwarding test is folded into one table on the real session manager (encode, copy with copied audio, copy with encoded audio), and the recordTranscodeStreamDetails comment no longer cites issue history. Both threads are resolved.

Remaining for maintainers:

  • After an API server restart, a session that copies video is rebuilt from its recipe card, which restores the negotiated targets the copy never applies. The admin view then shows them again. Main does the same today, so I filed [bug] Admin activity shows encode targets for a Jellyfin remux after a server restart #3100 rather than widening this PR. A fix in the shared rebuild code would overlap this PR's copy check, so it should follow this PR.
  • Jellyfin-compatible encodes target the client's bitrate ceiling, not the source bitrate (compatEncodeTarget). A client that sends a high MaxStreamingBitrate, such as 120 Mbps, and needs only a codec change now sees about 113.8 Mbps as the target and stream bitrate, where the view used to show the source bitrate. That figure is the cap FFmpeg really receives, so the PR reports it correctly. Whether the encode should also be capped at the source bitrate is a separate decision about the existing encode target.

Verification: TestRecordTranscodeStreamDetailsTargets fails on main in all three rows and passes on this head. The jellycompat, playback, admin handler and reconciler package tests pass, except TestCopyRemuxSubtitleRenditionRealFFmpeg, which fails the same way on untouched main with the local FFmpeg. go vet ./internal/... and changed-line lint are clean. The earlier sandbox run on ecca6cf0 still covers the visible behavior, because the later commits only merge main and change tests and a comment. Remote-node execution was not exercised live.

Validated features: no passed case is affected. #1206 C1 and #1207 C1 cover the admin session details this changes and are Not run. #1246 C1–C3 are unaffected. Validation tasks: none.

Parity and manual: the response fields already existed, and native sessions already fill them, so Apple, Android and web need no change. The user manual doesn't describe these values, so it needs no update.

Review method: Claude Code (claude-opus-5-5) with three read-only finder subagents and a validation check, followed by a Codex (gpt-6.1-sol, xhigh) cross-provider round. The Codex round could only read the diff and found nothing.

Fit: 9/10 · Readiness: 9/10 — ready. CI passed on 6af23438. Fit: it fixes a gap in the existing admin activity view where the execution facts are recorded, with no new surface. Readiness: the behavior is covered by tests that fail on main and was shown on a sandbox earlier. The two remaining points predate this PR.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-921/

Quick104 and others added 3 commits October 13, 2026 13:41
Main's Silo-Server#2817 removed TestSetTranscodeStreamDetails and
TestRecipeCardLegacyDecodeHasEmptyPlayMethod as low-value. This branch had
extended the first for the target resolution and bitrate; take main's
removal. The jellycompat tests here still check that sessions report both.

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.

Reviewed 2366605f. No correctness defect in the change itself. Two small cleanups are inline, and I'm fixing both in a commit on this branch, so there's no need to change anything yourself. Two related problems that predate this PR are in the summary comment.

…nager

Fold the fake-backed forwarding test into the copy-target table, which
drives the real SessionManager, and drop the issue history from the
recordTranscodeStreamDetails comment.

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

macroscopeapp Bot commented Oct 26, 2026

Copy link
Copy Markdown

The change affects the admin Activity view: transcodes should show their actual target resolution and bitrate, while copied video should retain source-based values. The private Evidence page should let reviewers verify before-and-after captures of the same session on desktop and mobile, including an encoded session and the copy-stream case. The PR describes desktop and mobile captures of the copy-stream correction and includes an evidence link; I could not inspect the private page.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@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/L 200–499 added + deleted lines (all files); change volume, not priority. labels Oct 26, 2026
@Quick104
Quick104 merged commit a5754e5 into Silo-Server:main Oct 26, 2026
20 checks passed
@rangoDJ
rangoDJ deleted the fix/jellycompat-transcode-target-telemetry-920 branch November 15, 2026 00:45
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/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jellycompat sessions show source resolution/bitrate instead of actual transcode target in admin panel

2 participants