Visitar URL original
HLS: SDR variant selected over PQ variant with the same BANDWIDTH · Issue #3441 · androidx/media · GitHub
Skip to content

HLS: SDR variant selected over PQ variant with the same BANDWIDTH #3441

Open

Description

@connor-grady

Version

Media3 main branch

More version details

8cabac1

Devices that reproduce the issue

Not device-specific. Reproduces in a Robolectric test.

Reproducible in the demo app?

Not tested

Reproduction steps

Multivariant playlist with a PQ variant followed by SDR variants at the same BANDWIDTH (Jellyfin serves this when it can remux an HDR source):

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=60000000,AVERAGE-BANDWIDTH=60000000,VIDEO-RANGE=PQ,CODECS="hvc1.2.4.L153.B0,mp4a.40.2",RESOLUTION=3840x2160,FRAME-RATE=23.976
hdr_hevc.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=60000000,AVERAGE-BANDWIDTH=60000000,VIDEO-RANGE=SDR,CODECS="hvc1.1.4.L153.B0,mp4a.40.2",RESOLUTION=3840x2160,FRAME-RATE=23.976
sdr_hevc.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=60000000,AVERAGE-BANDWIDTH=60000000,VIDEO-RANGE=SDR,CODECS="avc1.640033,mp4a.40.2",RESOLUTION=3840x2160,FRAME-RATE=23.976
sdr_h264.m3u8
  1. Configure an HEVC decoder supporting Main, Main10 and Main10HDR10.
  2. Build the player with DefaultBandwidthMeter and an initial estimate of 4,300,000 (the highest default Wi-Fi estimate).
  3. Prepare the playlist and check the track format of the first media chunk load.

Expected result

The PQ variant is selected.

Actual result

The HEVC SDR variant is selected. With an initial estimate of 1,000,000,000 the PQ variant is selected.

Media

Playlist above. The segments can be any fMP4 segments.

Cause

  • HlsPlaylistParser only sets colorInfo for Dolby Vision variants (L541-L546), so VIDEO-RANGE=PQ is dropped and the HDR preference in DefaultTrackSelector (L4036) never applies.
  • VideoTrackInfo.isCompatibleForAdaptationWith (L3950) does not compare HDR and SDR, so both HEVC variants share one adaptive selection. When neither fits the allocated bandwidth, AdaptiveTrackSelection.determineIdealSelectedIndex (L697-L717) returns the last one, which is the SDR variant.

Proposed fix

  1. Map VIDEO-RANGE to Format.colorInfo for every variant.
  2. Keep HDR and SDR tracks out of the same adaptive selection.

Both would select HDR on an SDR display unless HDR10 and HLG are checked against display capabilities (#1074). I can open PRs for 1 and 2.

Activity

  1. tonihei commented on Oct 8, 2026

    @tonihei
    Collaborator

    Thanks for highlighting this issue again. We are aware of some track selection gaps in relation to HDR tracks and this is one of them. We not only need to keep them out of the same selection, but also make sure the prefer the right one according to display capabilities.

  2. self-assigned this
    on Oct 8, 2026
  3. a-lyons commented on Oct 11, 2026

    @a-lyons

    Caveat: I'm not a software developer. I used AI to help troubleshoot my setup and draft this comment. I just want to help and provide additional information!

    Another real-device repro, with a trigger not covered above: the HDR format is fully supported and only the audio needs transcoding.

    Setup

    • Sony BRAVIA 4K UR2 (Android 10), Jellyfin for Android TV 0.19.10 (Media3 1.8.0), Jellyfin server 12.2.0
    • Source: 2160p HEVC Main 10, Dolby Vision Profile 8.1 (HDR10-compatible base layer), DTS-HD MA 7.1, MKV
    • Display reports DV / HDR10 / HLG; HEVC decoder reports DV / HDR10 / HDR10+; hardware OMX.dolby.vision.dvhe.* decoders are present. The same file direct plays (progressive MKV) on this device without issue.

    Trigger
    Enabling the app's "downmix to stereo" option restricts audio to AAC/MP3/MP2 with ≤2 channels. The server then plans a remux: copy the video and transcode only the audio (TranscodeReasons=AudioCodecNotSupported, no video reasons). It serves the same multivariant shape as the original report: the PQ copy variant first, then SDR transcode variants at identical BANDWIDTH.

    Result
    Every media segment requested came from an SDR variant:

    • With the PQ hvc1 Main 10 + SDR hvc1 Main + SDR avc1 variants: SDR HEVC was selected.
    • With HEVC encoding disabled on the server (PQ hvc1 Main 10 + SDR avc1 only): SDR H.264 was selected over the PQ HEVC variant.

    The server ends up doing a full 4K decode → tone-map → re-encode for a stream the device could play untouched, and the viewer gets SDR instead of DV/HDR10.

    In case it's useful: in the second case, selection moved to a different codec rather than to the PQ variant. So an HDR preference might need to apply across MIME types too, not only between same-codec variants. That's a guess from the outside, though.

    Happy to test a build or share more logs.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions