Repository navigation
fix(sessions): Swiftfin AVPlayer gets HDR HEVC as a copy instead of an SDR H.264 transcode - #604
Merged
braedonsaunders merged 2 commits intoNov 20, 2026
Conversation
Owner
|
Thanks, reviewed and merged into the 0.3.16 branch; it lands on main with the 0.3.16 release candidate (this PR will show as merged then). Evaluating VideoCodecTag against the fMP4 sample entry Ether actually writes is the right fix, and RESOLUTION/FRAME-RATE on the sessions master matches what the Plex master already sends. Thanks for the device table. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Swiftfin's native player (AVPlayer, tvOS/iOS) never gets HEVC from Ether. An HDR10 or Dolby Vision HEVC MKV is re-encoded to H.264 and tone mapped to SDR, even though the client declares HEVC, HDR10 and Dolby Vision. When the re-encode is avoided, HDR titles still don't play: AVPlayer fetches the master playlist and gives up.
There are two separate causes, one per commit.
1.
VideoCodecTagis evaluated against the source containerSwiftfin's AVPlayer profile accepts HEVC only with a required sample entry tag (
MediaPlayerType+AVPlayer.swift):profileDeliveryAllowedchecks the copied stream'sCodecTagfrom the source. Matroska has no sample entry, so the tag is empty, the required condition fails, and only the H.264 encode passes. The fMP4 segments Ether writes do carry a sample entry: the transcoder tags HEVChvc1(dvh1for a copied DV profile 5 source) and H.264avc1.Fix: for an fMP4 decision,
profileDeliveryAllowedstamps the output stream with the sample entry the transcoder will write (fmp4VideoTag), so the condition is evaluated against what the client actually receives.2. The single-variant HLS master has no
RESOLUTIONorFRAME-RATEWith (1) applied, SDR HEVC copies played, but every PQ copy failed. The traefik access log for a DV 8.1 title shows the pattern each time:
master.m3u8fetched twice, no variant playlist request,Sessions/Playing/Stoppedabout 3 s later. The same title transcoded to SDR H.264 with the same 38 subtitle renditions played, so only the variant line differed:The CODECS / VIDEO-RANGE / SUPPLEMENTAL-CODECS values match Apple's own DV 8.1 example and what Jellyfin sends. What is missing are
RESOLUTIONandFRAME-RATE, which the HLS authoring spec requires on every video variant (9.2, 9.15). tvOS AVPlayer tolerates their absence for SDR but rejects a PQ / Dolby Vision variant without them. Ether's Plex master already writes both; the sessions master (Jellyfin/Emby/Vela) did not.Fix: new
transcode.HLSVariantGeometryreturnsRESOLUTION(source size for a copy,decisionOutputSizefor an encode) andFRAME-RATE(omitted when unknown, nothing at all when the size is unknown), andBroker.serveMasteradds it to the single-variant line. The ladder path already had both.Tests
TestSwiftfinAVPlayerCopiesHEVCIntoFMP4: with Swiftfin's AVPlayer profile, an HDR10 HEVC MKV is copied into fMP4 (no tone map, no H.264), and a source taggedhev1is accepted as well. Fails without the first commit.TestHLSVariantGeometry: copy keeps source geometry and ignores a height cap, an encode follows the encoded size, unknown frame rate or size, audio only.go vet,gofmtandgo test ./internal/transcode/ ./internal/sessions/ ./internal/frontends/...pass on Go 1.27.4.Verified on a device
Applied to v0.3.15 and tested with Swiftfin tvOS (AVPlayer) on Apple TV 4K:
The master now served for Madden:
Its init segment has an
hvc1sample entry withhvcCanddvvC, so Dolby Vision is available with the HDR10 base layer as fallback.Not addressed here: the master still has no
AVERAGE-BANDWIDTH(also a MUST in 9.14); AVPlayer did not need it in these tests.