Skip to content

fix(jellycompat): report hls sub-protocol only for sources played via TranscodingUrl - #2934

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/2879-transcoding-subprotocol
Oct 23, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/2879-transcoding-subprotocol

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2879
Related issue: N/A
Validation tasks: unblocks #1246 C1

Jellyfin Web in Chrome, Firefox and Android browsers cannot direct play a file that Silo can also transcode. The video stays on the loading spinner. This change makes PlaybackInfo report TranscodingSubProtocol: "hls" only on sources the client will play through the HLS TranscodingUrl, as Jellyfin does.

Silo set TranscodingSubProtocol to hls on every media source. Jellyfin Web plays the static /Videos/{id}/stream.{container} URL whenever SupportsDirectPlay or SupportsDirectStream is true, but it picks hls.js from TranscodingSubProtocol alone. hls.js then gets a raw MKV and fails with manifestParsingError.

Approach

mediaSourceDTO now reports hls only when the source supports transcoding and neither direct flag is set. Every other source reports http, which is Jellyfin's default. Item-detail media sources always claim direct play and carry no TranscodingUrl, so they report http too. The field is always present because Kotlin SDK clients fail to deserialize a response without it.

Other Jellyfin clients, checked against their source:

  • jellyfin-android reads the field only when it plays the transcode URL, and it still gets hls there.
  • jellyfin-androidtv and Findroid never read it.
  • Swiftfin shows it only as a label.

The Jellyfin Web retry after a failed direct play (direct play and direct stream disabled) is a transcode-only source, so it still gets hls.

Jellyfin leaves out TranscodingUrl on direct-play sources, while Silo keeps it, so Swiftfin plays the HLS URL even when it could direct play. That is older behavior, out of scope here.

Validation

  • go test ./internal/jellycompat/...: the new table test fails before the fix and passes after it. Two DV-strip tests (TestPlaybackInfoWithoutStripOrToneMapStillHasNoRoute, TestPlaybackInfoSkipsStripWhenRPUCannotBeStripped) also fail locally on unchanged main, because the local FFmpeg build differs from CI's. CI on main passes them.
  • go vet ./internal/jellycompat/, gofmt, goimports and make lint-changed: clean.
  • make verify-local-paths: clean.
  • Not run: the rest of the full pre-PR gate and a manual check in Jellyfin Web against a running server.

Evidence

PlaybackInfo response for an h264/AAC MKV, using a Chrome-like device profile (direct play mkv/mp4 h264+aac, HLS ts transcoding), trimmed to the fields involved. Captured by calling the PlaybackInfo handler in-process (not a committed test) on main and on this branch.

Request Before After
Direct play allowed SupportsDirectPlay: true, SupportsDirectStream: true, TranscodingSubProtocol: "hls" SupportsDirectPlay: true, SupportsDirectStream: true, TranscodingSubProtocol: "http"
Direct play and direct stream disabled SupportsDirectPlay: false, SupportsDirectStream: false, TranscodingSubProtocol: "hls" unchanged, TranscodingSubProtocol: "hls"

Item detail (GET /Users/{userId}/Items/{id}), MediaSources[] for the same file: TranscodingSubProtocol was "hls" and is now "http". These sources set SupportsDirectPlay: true and carry no TranscodingUrl; the value is a constant in detailMediaSourceDTO.

Full excerpts

Before:

Direct-play-capable request:
{
  "Container": "mkv",
  "SupportsDirectPlay": true,
  "SupportsDirectStream": true,
  "SupportsTranscoding": true,
  "TranscodingContainer": "ts",
  "TranscodingSubProtocol": "hls",
  "TranscodingUrl present": true
}
Transcode-only request (EnableDirectPlay/EnableDirectStream false):
{
  "Container": "mkv",
  "SupportsDirectPlay": false,
  "SupportsDirectStream": false,
  "SupportsTranscoding": true,
  "TranscodingContainer": "ts",
  "TranscodingSubProtocol": "hls",
  "TranscodingUrl present": true
}

After:

Direct-play-capable request:
{
  "Container": "mkv",
  "SupportsDirectPlay": true,
  "SupportsDirectStream": true,
  "SupportsTranscoding": true,
  "TranscodingContainer": "ts",
  "TranscodingSubProtocol": "http",
  "TranscodingUrl present": true
}
Transcode-only request (EnableDirectPlay/EnableDirectStream false):
{
  "Container": "mkv",
  "SupportsDirectPlay": false,
  "SupportsDirectStream": false,
  "SupportsTranscoding": true,
  "TranscodingContainer": "ts",
  "TranscodingSubProtocol": "hls",
  "TranscodingUrl present": true
}

Surface and build: jellycompat POST /Items/{id}/PlaybackInfo, main at 3bc9e58 compared with this branch.

Risks

A Jellyfin client that played the TranscodingUrl on a direct-play or direct-stream source and read TranscodingSubProtocol to pick an HLS player would now see http. None of the clients checked above do this.

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, GitHub 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 branch diff (claude-opus-5-5 and gpt-6.1-sol) covering correctness, repository standards, and the issue's requirements. Neither found anything.

Note

Report HLS sub-protocol only for transcode-only sources in jellycompat

Fixes TranscodingSubProtocol in Jellyfin media-source DTOs. It now defaults to HTTP and reports HLS only when a source can be played via a TranscodingUrl (transcoding supported without direct play or direct stream).

  • Adds named constants for the HTTP and HLS MediaStreamProtocol values in dto.go and uses them instead of string literals
  • Changes catalog media sources in mapping.go to report HTTP instead of HLS
  • Adds table-driven contract tests covering direct-play, direct-stream, transcode-only, and no-capability sources in playback_contract_test.go
  • Behavioral Change: clients now see HTTP for direct-play and direct-stream sources that previously saw HLS; check PlaybackHandler.mediaSourceDTO and detailMediaSourceDTO

Macroscope summarized 22ef246.

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

silo-kody Bot commented Oct 22, 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 22, 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: 720509a6-611c-4dc5-a06c-7c52d9b6bbf8
📥 Commits

Reviewing files that changed from the base of the PR and between e122e78 and 22ef246.

📒 Files selected for processing: 1
  • internal/jellycompat/handlers_playback.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.

📝 Walkthrough

Playback DTOs now report http for direct-play and direct-stream sources. They report hls for transcode-only sources. Contract tests cover these selections and sources with no supported playback method.

Changes: Playback protocol selection

Layer / File(s) Summary
Protocol values and playback DTO selection
internal/jellycompat/dto.go, internal/jellycompat/handlers_playback.go, internal/jellycompat/mapping.go, internal/jellycompat/playback_contract_test.go
The playback DTO defaults TranscodingSubProtocol to http and uses hls only for transcode-only sources. The detail media source DTO uses the HTTP protocol constant. Contract tests cover direct play, direct stream, transcode-only, and unsupported playback sources.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to 22ef2

The playback protocol change matches the supported playback paths and introduces no actionable merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: report HLS only for sources played through TranscodingUrl.
Description check Passed The description directly explains the Jellyfin playback issue, the implementation, affected behavior, validation, and scope.
Linked Issues check Passed Issue #2879 requires direct-play sources to use the native playback path and requires TranscodingSubProtocol to report HLS only when the client uses the HLS TranscodingUrl. mediaSourceDTO now re…
Out of Scope Changes check Passed The changed constants, playback mapping, detail mapping, and contract test directly support issue #2879. The changes do not introduce unrelated product behavior or unrelated files. The reported Swiftf…
Full details: Linked Issues check

Explanation

Issue #2879 requires direct-play sources to use the native playback path and requires TranscodingSubProtocol to report HLS only when the client uses the HLS TranscodingUrl. mediaSourceDTO now reports http when direct play or direct stream is supported and reports hls only for transcode-only sources. detailMediaSourceDTO reports http for item-detail sources. TestTranscodingSubProtocolFollowsPlayedURL covers direct play, direct stream, transcode-only, and unsupported sources. These changes satisfy the linked coding requirements.

Full details: Out of Scope Changes check

Explanation

The changed constants, playback mapping, detail mapping, and contract test directly support issue #2879. The changes do not introduce unrelated product behavior or unrelated files. The reported Swiftfin behavior remains outside this change, as stated in the PR description.

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

The item-detail media source in internal/jellycompat/mapping.go changes TranscodingSubProtocol from hls to http, but the excerpts only show POST /Items/{id}/PlaybackInfo; add before-and-after API response excerpts for the same item-detail request.

Suggested fix: No diff — include the item-detail response excerpt before and after, trimmed to the changed field.

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

Posted via Macroscope — Visible change evidence

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

#1246 C1 is Not run, so this PR does not unblock a failed or blocked result. The changed POST /Items/{id}/PlaybackInfo response changes the direct/HLS choice that C1’s play step exercises. The PR should explain why this playback behavior changes; C1 has no validated build to re-check and needs validation on a post-merge build. Replace the body line with:

Validation tasks: changes #1246 C1

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

Posted via Macroscope — v1 validation impact

@Rhainland

Copy link
Copy Markdown
Contributor Author

Updated the line to Macroscope's suggestion: Validation tasks: changes #1246 C1. #1246 C1 is Not run, and its play step goes through the PlaybackInfo response this PR changes. C2 and C3 cover restrictions and the documented boundary, which this PR doesn't touch.

@Rhainland

Rhainland commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Checked against a running server while validating #1246 C1: Jellyfin Web 12.1 in Google Chrome, synthetic h264/AAC and HEVC/AC-3 MKV files, a child profile and a separate restricted account.

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

One low-severity finding, below. The change itself checks out against Jellyfin Web 10.10.7, 10.11.0 and current master, which all play stream.{container} when either direct flag is set, and against jellyfin-android, whose only HLS requirement is in its transcode branch, chosen under the same predicate this PR uses.

Rhainland and others added 2 commits October 23, 2026 14:49
… TranscodingUrl

PlaybackInfo set TranscodingSubProtocol to hls on every media source,
including direct-play and direct-stream ones. Jellyfin Web plays those
through the static stream URL but chooses hls.js from this field alone,
so Chrome handed a raw MKV to hls.js and playback never started.

Report hls only when the source can only be played through its
TranscodingUrl, and http (Jellyfin's default) otherwise, including on
item-detail media sources.

Closes Silo-Server#2879
Swiftfin plays any TranscodingUrl it receives, so the comment's claim
that Jellyfin clients play the direct URL whenever a direct flag is set
did not hold for every client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the fix/2879-transcoding-subprotocol branch from e122e78 to 22ef246 Compare October 23, 2026 18:50
@silo-kody

silo-kody Bot commented Oct 23, 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: 22ef246 (the original commit rebased onto current main, plus one comment fix). The branch was rewritten by a force-push with lease; there were no conflicts.

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

  • Fit: a bounded Jellyfin-compatibility fix that makes Silo report the field the way Jellyfin does. It adds no setting and no new surface.
  • Readiness: TestTranscodingSubProtocolFollowsPlayedURL fails on the base ("hls", want "http") and passes on this head. go test ./internal/jellycompat/, make lint-changed, the size-ratchet, bidi and local-path checks pass on current main.

Addressed

  • The comment above the new rule said Jellyfin clients play the direct URL whenever a direct flag is set. Swiftfin doesn't: it plays any TranscodingUrl. Fixed in 22ef246.

Checked and not a problem

  • Jellyfin Web 10.10.7, 10.11.0 and current master play stream.{container} when either direct flag is set. They never direct play a Protocol: "File" source in a browser, so a source with direct play on and direct stream off still goes to the static URL, not to TranscodingUrl.
  • jellyfin-android picks its transcode branch, the only place it requires hls, under the same predicate this PR uses.
  • Every flag change happens before mediaSourceDTO is called. Item-detail sources carry no TranscodingUrl.
  • No fixtures, docs or snapshots assert "hls".
  • fix(jellycompat): accept an empty stream index in playback requests #2970 changes how the playback request is decoded. It merges cleanly with this branch and the two don't interact.

Left for maintainers

Validated features

No passed case on the v1.0 board is reached by this change. #1246 C1 is Not run and fails on the base for Jellyfin Web, so I changed the body's line to Validation tasks: unblocks #1246 C1.

Other checks

  • User manual: unaffected.
  • Apple/Android: no change needed; the first-party apps use the native API, not jellycompat.
  • Independent review: gpt-6.1-sol, one round, found the Swiftfin comment issue above and nothing else.

@macroscopeapp

macroscopeapp Bot commented Oct 23, 2026

Copy link
Copy Markdown

The item-detail evidence states the old and new TranscodingSubProtocol values, but it does not identify the build or commit for those captures; the surface/build line names only the PlaybackInfo endpoint. Please attribute the item-detail before-and-after response to the main and PR builds.

Suggested fix: No diff — add the main and PR build/commit identifiers for the item-detail response excerpt.

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

Posted via Macroscope — Visible change evidence

@macroscopeapp

macroscopeapp Bot commented Oct 23, 2026

Copy link
Copy Markdown

This PR unblocks the #2879 direct-play finding under #1246 C1. The 23 Oct task update records it on the base build; this change alters the protocol field behind Jellyfin Web’s HLS selection. That update’s fix-stack run is unpublished and awaits human acceptance, and C1 still needs a published-build re-test after the separate #2970 series-page fix ships. The ## Results row still says Not run; leave it so until a human records the result.

Please update the PR line to:

Validation tasks: unblocks #1246 C1

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

Posted via Macroscope — v1 validation impact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S 0–49 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Jellyfin Web in Chrome cannot direct play because PlaybackInfo always says TranscodingSubProtocol hls

2 participants