Skip to content

fix(jellycompat): leave TranscodingUrl off sources the client can direct play - #3104

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
rangoDJ:fix/jellycompat-no-transcodingurl-on-direct-2981
Nov 5, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
rangoDJ:fix/jellycompat-no-transcodingurl-on-direct-2981

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2981
Related issue: N/A
Validation tasks: none

Jellyfin-compat PlaybackInfo published a TranscodingUrl on every media source that supports transcoding, including sources that also allow direct play or direct stream. Jellyfin sets it only when it chooses to transcode. Swiftfin plays any TranscodingUrl before the direct URL, so it streamed over HLS even for files it could direct play, and the server did remux or transcode work for each of those sessions.

Approach

mediaSourceDTO now leaves TranscodingUrl and TranscodingContainer off any source the client can direct play. A direct-stream-only source keeps them: Swiftfin with a Custom → Replace profile (MP4/H.264/AAC direct play, TS transcoding) negotiates exactly that for an MKV, and without a TranscodingUrl it builds its own Static=true URL and gets the original MKV instead of the remux. TranscodingSubProtocol is unchanged: hls only on a transcode-only source. A client whose direct play fails asks for PlaybackInfo again with the direct flags off (Jellyfin Web does) and gets a transcode-only source. Tests that built a direct-play source and expected a URL now build a transcode-only one, and a new test covers the four direct-flag combinations.

Validation

  • go test ./internal/jellycompat/: passes except TestPlaybackInfoWithoutStripOrToneMapStillHasNoRoute and TestPlaybackInfoSkipsStripWhenRPUCannotBeStripped, which fail the same way on a clean main in my local environment.
  • Not tested against a real Swiftfin client (see Evidence); the issue was found by reading source.

Evidence

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

POST /Items/{id}/PlaybackInfo on a running server, before (latest, build-1905, e9c649b8c) and after (the same image, database and library with this branch's silo binary, e901deba2), using the profile the reviewer described for Swiftfin's Custom → Replace mode (direct play MP4 H.264/AAC, transcoding TS over HLS):

Source TranscodingUrl before after
H.264/AAC MP4 (direct play) present omitted
H.264/AAC MKV (direct stream only) present present

There is no Swiftfin playback result: I have no Apple device, so the change from HLS to direct play in that client is inferred from Swiftfin's source (it plays any TranscodingUrl first), not observed.

Risks

Clients that fall back to TranscodingUrl after a failed direct play of a direct-play source without requesting PlaybackInfo again would no longer find one. Jellyfin Web requests it again, and Jellyfin itself behaves this way, so I expect no regression, but other clients are unverified.

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
  • Tool(s): Claude Code, GitHub CLI
  • Model(s): claude-sonnet-5-5
  • Involvement: AI-assisted
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Omit TranscodingURL from direct-play-capable sources in jellycompat

The media-source DTO builder in handlers_playback.go now emits TranscodingURL and TranscodingContainer only when the source supports transcoding and cannot direct play. Direct-stream-only and transcode-only sources keep the HLS route, since Swiftfin needs it for the direct-stream remux case.

  • Tests updated to configure transcode-only sources before asserting the audio-v2 HLS, MPEG-TS remux, and Dolby Vision strip routes.
  • Adds a table-driven test covering four combinations of direct-play/direct-stream support and checks TranscodingURL, TranscodingContainer, and TranscodingSubProtocol in each case.
  • Behavioral Change: clients that read TranscodingURL from a direct-play source now see it empty; see PlaybackHandler.mediaSourceDTO in handlers_playback.go.

Macroscope summarized e901deb.

…ect play

mediaSourceDTO published a TranscodingUrl on every source that supports
transcoding, including sources that also set SupportsDirectPlay or
SupportsDirectStream. Jellyfin sets TranscodingUrl only when it chooses to
transcode. Swiftfin plays any TranscodingUrl before the direct URL, so it
streamed over HLS even for files it could direct play, and the server spent
remux or transcode work on every such session.

Only a transcode-only source now carries TranscodingUrl and
TranscodingContainer. A client whose direct play fails asks for PlaybackInfo
again with the direct flags off (Jellyfin Web does) and gets one.

Fixes Silo-Server#2981

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 26, 2026
@silo-kody

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

@coderabbitai

coderabbitai Bot commented Oct 26, 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: 8cb687bf-6618-4113-8f83-109471751f82
Commits

Reviewing files that changed from the base of the PR and between 651fc2a and e901deb.

Files selected for processing: 2
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/routing_policy_test.go
Files skipped from review as they are similar to previous changes: 1
  • internal/jellycompat/routing_policy_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.

Walkthrough

Playback metadata no longer includes TranscodingURL for sources that support direct play. Tests cover metadata selection and route generation for transcode-only sources.

Changes: Playback metadata and routing

Layer / File(s) Summary
Transcoding metadata selection
internal/jellycompat/handlers_playback.go, internal/jellycompat/playback_info_source_id_test.go
The DTO omits TranscodingURL when direct play is supported. Tests check transcoding fields and HLS subprotocol selection across direct-play and direct-stream capability combinations.
Transcode-only route validation
internal/jellycompat/audio_v2_routes_test.go, internal/jellycompat/hevc_routes_test.go, internal/jellycompat/playback_info_source_id_test.go, internal/jellycompat/routing_policy_test.go
Route tests disable direct play and direct stream before checking audio, HEVC, MPEG-TS, and Dolby Vision routes. Two playback-info test cases also disable direct streaming. A comment identifies direct streaming as a remux.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • Silo-Server/silo-server#2934: Both changes define playback metadata conditions. That PR updates TranscodingSubProtocol; this PR updates TranscodingURL behavior.

Suggested labels: impact: playback

Suggested reviewers: quick104

Merge Risk: Minimal · up to e901d

The metadata change and associated route tests align with the stated direct-play and transcode-only behavior.

Security architecture risk: Minimal · up to e901d

The change withholds unnecessary transcoding URLs without expanding media permissions or adding playback routes. Direct-stream-only sources retain their remux fallback. No introduced or worsened security issue was identified; real-client playback compatibility remains unvalidated.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed exposure is client route preference for already negotiated media sources, not additional assets, privileges, services, or credentials. The direct-play route was already advertised for these sources.

Trust Boundaries and Controls

  • observed — Media routes retain their existing authentication middleware. It accepts credentials or a matching playback-session grant, and also has a pre-existing credentialless static-stream exception tied to a live, recently active negotiation from the same client address. Shared-address clients can reuse that exception for the matching source; this limitation predates the PR and its grant conditions are unchanged.
Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Linked Issues check Warning Issue [#2981] requires no TranscodingUrl for a source that supports direct play or direct stream. mediaSourceDTO omits the URL only when !source.SupportsDirectPlay. A direct-stream-only source s… Update mediaSourceDTO so direct-stream-capable sources also omit TranscodingUrl and TranscodingContainer. Update the direct-flag test to require omission for direct-stream-only sources. Preserve the required transcode-only route behav…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title names the main change: mediaSourceDTO omits TranscodingUrl for sources the client can direct play. It matches the raw summary and the PR objectives. It is specific and short, so it passes.
Out of Scope Changes check Passed The production change addresses the PlaybackInfo behavior in [#2981]. The test changes support this objective by separating direct-play-capable sources from transcode-only route cases and by coverin…
Description check Passed The pull request description directly explains the TranscodingURL change, its impact on direct play and direct stream behavior, the test updates, validation results, evidence, and known risks.
Full details: Out of Scope Changes check

Explanation

The production change addresses the PlaybackInfo behavior in [#2981]. The test changes support this objective by separating direct-play-capable sources from transcode-only route cases and by covering the direct-flag combinations. No unrelated change appears in the reviewed diff.

Full details: Linked Issues check

Explanation

Issue [#2981] requires no TranscodingUrl for a source that supports direct play or direct stream. mediaSourceDTO omits the URL only when !source.SupportsDirectPlay. A direct-stream-only source still receives TranscodingUrl and TranscodingContainer. The new table-driven test explicitly expects that result, so the implementation and test do not meet the linked issue requirement.

Resolution

Update mediaSourceDTO so direct-stream-capable sources also omit TranscodingUrl and TranscodingContainer. Update the direct-flag test to require omission for direct-stream-only sources. Preserve the required transcode-only route behavior.

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

@macroscopeapp

macroscopeapp Bot commented Oct 26, 2026

Copy link
Copy Markdown

The jellycompat PlaybackInfo response no longer includes TranscodingUrl or TranscodingContainer for direct-play/direct-stream-capable sources, changing playback selection for clients such as Swiftfin. Please add before-and-after response excerpts for the same request and identify the surface and build or commit.

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

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: compat Breaks a supported client or server path priority: P2 Limited scope, workaround exists, or polish labels Oct 26, 2026
@silo-triage

silo-triage Bot commented Oct 26, 2026

Copy link
Copy Markdown

The Evidence section says there is no user-visible change, but this fix is intended to switch Swiftfin from HLS to direct playback. Please replace that statement with before-and-after PlaybackInfo excerpts for the same direct-capable source, showing the changed transcode fields, and a real Swiftfin playback result confirming the selected playback method. Name the builds used and redact stream URLs and tokens; the description currently says Swiftfin was not tested.

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

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: 464cf06d-be46-4ec9-9bba-7bf14473f25c
Commits

Reviewing files that changed from the base of the PR and between 8cbc820 and e6b77b7.

Files selected for processing: 5
  • internal/jellycompat/audio_v2_routes_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/hevc_routes_test.go
  • internal/jellycompat/playback_info_source_id_test.go
  • internal/jellycompat/routing_policy_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.

@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 e6b77b75d65071aead2aeccb722e88fe42484093. One P2 remains: removing the HLS URL from direct-stream-only sources breaks a supported Swiftfin custom-profile configuration. The inline finding gives the trigger and repair.

The new DTO test passes on head and fails in its three direct-source cases against the merge-base implementation. Independent verification also negotiated the affected Swiftfin profile and confirmed that its resulting static request receives original MKV bytes on head, while base retains the HLS URL. No physical Swiftfin or AVPlayer playback was run; the default Swiftfin profile usually avoids this particular negotiation.

Validated features: update the line to Validation tasks: changes #1246 C1. The recorded 23 October playback pass is an agent runtime result on a local integration build, with human acceptance pending; the changed PlaybackInfo contract warrants revalidation. C2’s access checks are unchanged, and the 113 other recovered passed cells do not reach this DTO. Full project enumeration was unavailable because the token lacks read:project; live issue bodies and comments supplied the limited coverage. No validation records were changed.

The native API and first-party clients are unaffected. No manual correction was identified for the intended direct-play fix.

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

Reviewed with Codex and gpt-6.1-sol at xhigh, using independent review and verification passes. No product code was changed.

Swiftfin builds a Static=true URL when a source has no TranscodingUrl,
so a direct-stream-only source (an MKV under an MP4 direct-play profile)
fetched the original file instead of the remux. Only a source the client
can direct play leaves TranscodingUrl off.

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

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

@coderabbitai coderabbitai Bot added the impact: playback Can't play, stalls, or wrong media label Nov 2, 2026
@Quick104
Quick104 merged commit 2d5f22e into Silo-Server:main Nov 5, 2026
16 checks passed
Quick104 added a commit that referenced this pull request Nov 5, 2026
Resolves the routing policy test conflict with #3104 in favour of this
branch: the case sets EnableTranscoding=false, so no TranscodingUrl is
expected alongside the progressive remux.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rangoDJ
rangoDJ deleted the fix/jellycompat-no-transcodingurl-on-direct-2981 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 evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: compat Breaks a supported client or server path impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish 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] Jellycompat sends a TranscodingUrl on direct-play sources, so Swiftfin never direct plays

2 participants