Repository navigation
feat(jellycompat): copy video as MPEG-TS for clients that list only TS - #3341
Conversation
A client whose HLS profile accepts the source codecs in MPEG-TS but not in fMP4 got a full video encode, because copy negotiation tested fMP4 alone. It now gets a video copy in MPEG-TS, through the route Roku and webOS copies already use. A progressive remux the client can take still comes first. HLS carries only H.264 and HEVC in MPEG-TS, with AAC, AC-3, E-AC-3 or MP3 audio. Other audio converts to AAC when the profile accepts it.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The Jellycompat playback route now gives TS-only profiles a video copy instead of an encode ( Suggested fix: No diff — add the response excerpts to the Evidence section. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
MPEG-TS eligibility and selection internal/playback/plan_v3.go, internal/jellycompat/handlers_playback.go |
The planner checks H.264 or HEVC video and audio compatibility for MPEG-TS copying. Jellyfin-compatible negotiation selects TS when progressive remux is unavailable, the codecs fit, and the profile supports the applicable TS route. |
Container propagation and playback constraints internal/jellycompat/handlers_playback.go, internal/jellycompat/playback_sessions.go, internal/jellycompat/dv_strip.go, internal/jellycompat/*_test.go, docs/jellycompat-api.md |
Playback records the selected container and uses it for output packaging and audio-track support. Dolby Vision strip remux rejects TS packaging. Tests and API documentation cover container negotiation, audio handling, client profiles, and strip behavior. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant PlaybackInfo
participant PlaybackNegotiation
participant ClientProfile
PlaybackInfo->>PlaybackNegotiation: request playback source
PlaybackNegotiation->>ClientProfile: check container support
ClientProfile-->>PlaybackNegotiation: supported containers
PlaybackNegotiation-->>PlaybackInfo: selected container and remux flags
Possibly related issues
- [bug] Jellyfin-compat offers no route when progressive remux is off and the client direct-streams the source audio #3356: The PR changes audio-transcode HLS route selection, but the issue says the progressive-remux-unavailable case remains unresolved.
- [bug] Jellyfin-compat remote starts accept a node that ignores the MPEG-TS copy request #3355: The PR adds more Jellyfin MPEG-TS copy routes but does not add the attestation check described in the issue.
- [v1] Compatibility layers (Jellyfin / Audiobookshelf) #1245: The PR updates Jellyfin playback negotiation for TS-only clients, which addresses part of the parent issue’s playback requirements.
Suggested labels: impact: playback, impact: usability, impact: perf
Suggested reviewers: quick104
Merge Risk: 
Minimal · up to 715b4
-
TS negotiation and packaging are consistent on the reviewed paths. No merge-blocking risk remains identified.
Security architecture risk: 
Low · up to 715b4
-
The change broadens supported playback formats without an observed increase in access or privileges. Existing ownership and format-consistency checks remain in place, although concurrent recovery and mixed-version operation were not fully validated.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The demonstrated exposure change is additional authenticated client profiles reaching an existing media packaging path for their negotiated source. The inspected change does not establish broader asset access, cross-user session reuse, or additional execution privileges.
Trust Boundaries and Controls
- observed — HLS follow-up authentication resolves the negotiated playback session, and master, manifest, and segment consumers enforce its CompatToken ownership. Source and route validation remain separate checks after authentication.
- observed — The two routed test symbols are test functions, not new HTTP entrypoints. Their assertions cover TS packaging eligibility and rejection of the fMP4-only Dolby Vision stripping path for a TS-only client.
Resilience and Maintainability Implications
- observed — The existing negotiation identity includes the selected container, audio/subtitle choices, audio conversion, and Dolby Vision mode. Container changes therefore remain represented in session negotiation identity rather than relying on the temporary marker after persistence.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description is specific and tied to the changeset. It explains the problem (TS-only Jellyfin clients get full video re-encodes instead of copies), the approach in buildPlaybackSource and the new playback.HLSCopyFitsMPEGTS helper, the Dolby Vision strip exclusion, validation steps, end-to-end evidence, risks, and a follow-up fix commit. Its content matches the file summaries, so the check passes.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 9 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
| source.HLSRemuxMPEGTS = compatWebOSDVMPEGTS(r.UserAgent(), source) || compatRokuMPEGTS(r.UserAgent(), profile, source) || | ||
| source.hlsRemuxInTS && compatHLSCopiesVideo(source) && !source.DVStripToHDR10 |
There was a problem hiding this comment.
Unsupported fMP4 strip delivery occurs because applyCompatDVStrip now accepts TS-only copy negotiation, but PlaybackInfo disables MPEG-TS for DVStripToHDR10 and compatTranscodingContainer advertises fMP4, leaving a client that rejects the Dolby Vision source and accepts its HDR10 base layer only in TS without a supported stream. Exclude TS-only remuxes from strip selection unless the strip delivery path supports that container.
Prompt for LLM
File internal/jellycompat/handlers_playback.go:
Line 2352 to 2353:
Unsupported fMP4 strip delivery occurs because applyCompatDVStrip now accepts TS-only copy negotiation, but PlaybackInfo disables MPEG-TS for DVStripToHDR10 and compatTranscodingContainer advertises fMP4, leaving a client that rejects the Dolby Vision source and accepts its HDR10 base layer only in TS without a supported stream. Exclude TS-only remuxes from strip selection unless the strip delivery path supports that container.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5)
Confirmed, high severity. applyCompatDVStrip accepts the HDR10 base whenever stripped.HLSRemux is true. With this PR, that can now be a copy the client accepts only as MPEG-TS. PlaybackInfo then keeps the strip on fMP4 (!source.DVStripToHDR10 here), so the client gets remux-dv-v1 with TranscodingContainer: mp4, a container its profile never listed. Before this PR the strip was refused, and the client got the encode fallback, or no route when tone mapping was off.
Trigger: a Dolby Vision profile 8.1 HEVC file, and a client that rejects DOVIWithHDR10, lists HEVC only in a ts HLS profile, and can't take a progressive remux of HEVC. The new TestPlaybackInfoSkipsStripForTSOnlyClient gets a 200 with remux-dv-v1 on this head.
I'm fixing this in a commit on this branch, so there's no need to change it yourself. The strip will skip a TS-only copy (stripped.hlsRemuxInTS), as it did before. Packaging the strip as MPEG-TS would need its own route and recipe change.
There was a problem hiding this comment.
Fixed in 715b4d6. applyCompatDVStrip now returns the original source when the stripped negotiation is a TS-only copy (!stripped.HLSRemux || stripped.hlsRemuxInTS). TestPlaybackInfoSkipsStripForTSOnlyClient fails on 3fcb587 (200 with remux-dv-v1, TranscodingContainer: mp4) and passes now. The internal/jellycompat and internal/playback suites pass.
There was a problem hiding this comment.
Agreed—rejecting stripped.hlsRemuxInTS in applyCompatDVStrip addresses the container mismatch while keeping the existing fMP4 strip path intact. MPEG-TS strip delivery should remain a separate change.
For regression coverage, verify that the TS-only case never selects remux-dv-v1, falls back to encoding when available, and returns no playable route when tone mapping is disabled. An fMP4-capable profile should still retain the strip route.
I’ll leave the branch changes to you.
There was a problem hiding this comment.
Thanks—the guard in 715b4d693 addresses the reported mismatch: TS-only stripped negotiations are rejected, preserving the existing fallback behavior while leaving fMP4-capable strip routes intact.
The reported regression failure on 3fcb58729 and pass after the fix demonstrate coverage of the original bug. With both package suites passing, I consider this finding addressed based on your report.
| remuxAudioEncodeTS := !remuxAudioEncodeFMP4 && !progressiveRemuxOK && playback.HLSCopyFitsMPEGTS(version.CodecVideo, "") && | ||
| profile.supportsHLSRemuxWithAudioTranscodeIn(version, selectedAudioIndex, targetAudioChannels, compatContainerTS) |
There was a problem hiding this comment.
Blocked audio-only conversion occurs because the new TS AAC fallback requires !audioSupported, which reflects progressive MP4 compatibility rather than MPEG-TS audio support. For H.264/FLAC accepted by the direct-stream codec profile, a routing policy that forbids progressive remux sets remuxAudioCopyTS to false and remuxAudioEncodeTS to true while audioSupported remains true, forcing a full video encode or no playable route; gate the fallback on MPEG-TS audio compatibility instead.
Prompt for LLM
File internal/jellycompat/handlers_playback.go:
Line 2674 to 2675:
Blocked audio-only conversion occurs because the new TS AAC fallback requires !audioSupported, which reflects progressive MP4 compatibility rather than MPEG-TS audio support. For H.264/FLAC accepted by the direct-stream codec profile, a routing policy that forbids progressive remux sets remuxAudioCopyTS to false and remuxAudioEncodeTS to true while audioSupported remains true, forcing a full video encode or no playable route; gate the fallback on MPEG-TS audio compatibility instead.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5)
The mechanism is real, but this PR doesn't introduce it. main has the same (!allowAudioCopy || !audioSupported) gate, and it already blocks the fMP4 audio conversion the same way. A focused test on main (84cab92) with H.264/FLAC, a direct-play profile that accepts FLAC, an fMP4 HLS profile that lists only AAC, and RemuxExecution: worker_only returns no route at all (SupportsTranscoding=false). The fix changes the expression this PR edits, so I filed it as #3356 to follow this PR rather than widening this one.
There was a problem hiding this comment.
Agreed—your reproduction on main shows the gate is a pre-existing bug, not a regression introduced by #3341. My suggestion should have made that distinction.
Tracking the fix in #3356 is reasonable: the follow-up should make audio-only transcoding eligibility depend on the negotiated HLS container’s audio support, rather than progressive MP4 compatibility, covering both fMP4 and MPEG-TS. I wouldn’t treat this finding as a blocker for #3341.
…pies The Dolby Vision strip is packaged as fMP4, so a strip negotiated from a copy the client accepts only as MPEG-TS handed that client a container it never listed. The strip now skips such a copy, as it did before TS copies existed. The MPEG-TS audio check read the selected track's codec, which is empty on an untagged track, and treated it as a video-only check. It now uses the file codec fallback the profile match already uses, so FLAC or DTS is converted instead of copied into TS. Also drops a progressive-remux test from the TS audio-encode branch that could never change its result, and has the native planner use the shared MPEG-TS video rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5), maintainer review
The approach is sound, and I found two defects in the new MPEG-TS negotiation. I'm fixing both in a commit on this branch, so there's no need to change anything yourself.
- Dolby Vision strip sent as fMP4 to a TS-only client (high). Kody's thread on line 2353 already covers this. My reply there has the trigger and the test.
- Untagged audio track skips the MPEG-TS audio check (medium). See the inline comment.
There's also one cleanup in the inline comment on line 2674.
Kody's second finding (FLAC with progressive remux ruled out by policy) is real, but main has it too, and it hits fMP4 as well. I filed it as #3356 so it can follow this PR. While reviewing, I also found that jellycompat remote starts never check the node's MPEG-TS copy attestation. That predates this PR, but the PR sends more clients down that path. It's filed as #3355.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
🤖 Claude Code (claude-opus-5-5), maintainer review summary Reviewed head: 715b4d6 (the PR's 3fcb587 plus my review fixes) Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green) Fit. Jellyfin compatibility is a long-term commitment, and a Jellyfin server copies video into MPEG-TS for a client whose profile lists only TS. Encoding a stream the client could take as a copy wastes a transcode slot and lowers quality, which hurts most on small servers. The change stays inside jellycompat negotiation, reuses the existing Readiness. The approach is sound, and the two defects the review found are fixed. Two items hold the score below 9. No real TS-only client app has played the new route; the evidence is the author's scripted client with ffprobe, plus handler tests. The validation board couldn't be read in this run (see below). Addressed in 715b4d6
Tests that fail on the baseThe PR's handler-level row Other feedback
Left for the maintainers
Cross-provider reviewOne round by Codex (gpt-6.1-sol) on 3fcb587. It confirmed the Dolby Vision finding and agreed that the FLAC gate predates the PR. It found no path after PlaybackInfo that loses the TS packaging. Validated featuresValidation tasks: changes #1246 C1 The board couldn't be read in this run (the token lacks the project scope), so this line rests on #1246's recorded results. C1's smoke matrix covers clients that can fall back from direct play to HLS. Any client whose profile lists only TS would now get a copy where it used to get an encode. The recorded run excluded Roku. A re-check of #1246 C1 on a build with this change is worth asking for after merge. User manual and clients
|
|
The recorded #1246 C1 matrix covers H.264 direct play and HEVC HLS transcode, but does not exercise the new TS-only video-copy route. The PR must explain why validated playback behavior changes; #1246 C1 needs re-validation after merge with a real TS-only client/profile. Suggested fix: No diff — record the post-merge C1 re-run in #1246. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Problem
Related issue: N/A
Validation tasks: changes #1246 C1
A Jellyfin client that accepts H.264 or HEVC in MPEG-TS HLS, but not in fMP4, gets a full video encode of a file it could have played as a copy. That costs a transcode slot and CPU or GPU, and it lowers quality for no reason. On current
main, a 6 Mbps H.264 file sent to a TS-only client is re-encoded to about 29 Mbps. With this change the same client gets a video copy at the source's rate.Approach
Copy negotiation in
buildPlaybackSourcetested the profile's fMP4 HLS entries only. It now tests fMP4 first and falls back to MPEG-TS when the profile lists the source codecs there. The copy uses the same MPEG-TS route that Roku and webOS copies already use. A client that lists fMP4 keeps fMP4, and a progressive remux the client can take still comes first.HLS carries only H.264 and HEVC in MPEG-TS, with AAC, AC-3, E-AC-3 or MP3 audio.
playback.HLSCopyFitsMPEGTSholds that rule. Other audio converts to AAC when the profile accepts it.This only changes the Jellyfin-compatible surface, so
silo-appleandsilo-androidneed no follow-up.docs/jellycompat-api.mdis updated.Validation
internal/jellycompatpasses exceptTestAttachmentServesActualFontAndRejectsWrongRoute, which also fails onmainin my environment.internal/playbackfails the same real-FFmpeg tests asmainin my environment, which has an older host FFmpeg.make lint-changedreports 0 issues.go veton both packages andmake verify-local-pathsare clean.mainas images and ran each with a fresh database and a synthetic 40 s library. A scripted client calledPlaybackInfowith a TS-only profile, fetched the playlists and segments, and checked them withffprobeand FFmpeg 8.1.3-Jellyfin.#EXT-X-ENDLISTwith 960 of 960 frames and clean decoding. Segment timestamps match the playlist to within 0.125 s.make test-goand the rest of the full gate, and any real TS-only client app. Seeking was checked only against segments already produced.TestPlaybackInfoSkipsStripForTSOnlyClientand theuntagged track is judged by the file codecrow fail on 3fcb587 and pass now. The PR'sTS-only client takes the copy and needs no burnrow fails onmain.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3341/
Same request on the same synthetic file: a TS-only profile with direct play off and a 120 Mbps ceiling. Sizes are the first four segments.
main84cab92)libx264,-maxrate 113808k, 29.4 MB-c:v copy, MPEG-TS, 7.2 MBlibx264, audio to AAC, 29.4 MB-c:v copy, E-AC-3 kept, 7.8 MBlibx264, 29.5 MB-c:v copy, audio to AAClibx264to H.264, 35.4 MB-c:v copy, HEVC kept, 5.2 MB-c:v copy, fMP4-c:v copy, fMP4 (unchanged)Surface and build: jellycompat
PlaybackInfoand HLS output, images built frommain84cab92 and this commit.TranscodeReasonschanges fromVideoCodecNotSupportedtoContainerNotSupportedfor these requests.Risks
mainbefore this PR: [bug] Jellyfin-compat remote starts accept a node that ignores the MPEG-TS copy request #3355 (jellycompat remote starts don't check the node's MPEG-TS copy attestation; this PR sends more clients down that path) and [bug] Jellyfin-compat offers no route when progressive remux is off and the client direct-streams the source audio #3356 (no audio-only conversion when policy rules out progressive remux; its fix follows this PR).buildPlaybackSourceand a test at the same place inplayback_output_conditions_test.go.Checklist
AI Disclosure
Note
Add MPEG-TS HLS video-copy routes for TS-only clients in
jellycompatPlaybackHandler.buildPlaybackSourcein handlers_playback.go can now negotiate an MPEG-TS HLS copy route when the client profile supports the codecs in TS but not fMP4 and no progressive remux route exists. It also applies TS-aware checks to audio-transcode HLS routes.PlaybackHandler.HandlePlaybackInfoselects TS packaging for sources marked as MPEG-TS remuxes, unless Dolby Vision is being stripped to HDR10.playback.HLSCopyFitsMPEGTSin plan_v3.go limits TS copy routes to H.264 or HEVC video plus an HLS-native audio codec.supportedHLSRemuxAudioStreamIndexesfilters audio switch targets against the negotiated container, andPlaybackMediaSourcegains an unexportedhlsRemuxInTSmarker used only during PlaybackInfo.Changes since #3341 opened
PlaybackHandler.buildPlaybackSource, and extendedTestHLSCopyPackagesForTheContainerTheClientLists[715b4d6]PlaybackHandler.applyCompatDVStripthat returns the original source when the negotiated HLS remux uses MPEG-TS, and addedTestPlaybackInfoSkipsStripForTSOnlyClient[715b4d6]playback.PlanPlaybackV3with a call toHLSCopyFitsMPEGTS(source.VideoCodec, "")[715b4d6]Macroscope summarized 3fcb587.