Skip to content

HDR10+ and Dolby Vision missing dynamic metadata #2

Closed

Description

@DrHurt

I've tested the current implementation and these are my findings:

It's VERY fast. I'm super impressed.

Video:

  • DV P8.1: TV switches to HDR mode (not DV) and plays the HDR10 base layer, no DV dynamic metadata

  • DV P5: TV switches to HDR mode (not DV), purple/green video as no HDR10 layer in P5

  • HDR10+: TV switches to HDR mode (not HDR10+) and plays the HDR10 base layer without the "plus" metadata

  • HLG & HDR10: both play correctly, TV switches to HDR mode and colours play correctly.

In the other thread, I said you could use AVPlayer to decode & render videos but if you can achieve the same results via AVSampleBufferDisplayLayer then that's probably better.

Thanks again and good luck

Activity

  1. DrHurt commented on May 3, 2026

    @DrHurt
    ContributorAuthor

    Tested again the new Sodalite rebrand 0.4.0 build 13

    Same results:
    Static HDR:
    HLG & HDR10 - work as expected

    Dynamic HDR:
    HDR10+ --- plays HDR10 base layer (fallback)
    DV P8.1/8.4 --- plays HDR10/HLG base layer (fallback)
    DV P5 --- wrong colours (because no HDR10 fallback)

    TV does NOT switch to DV mode with any of the DV profiles tested.

  2. DrHurt commented on May 3, 2026

    @DrHurt
    ContributorAuthor

    @superuser404notfound

    I think I see a potential reason why DV is failing.

    CMVideoFormatDescription in videotoolbox setup is missing kCMVideoCodecType_DolbyVisionHEVC and dvcC

    Have a look here:
    Marginal/QuickLookVideo#158

  3. superuser404notfound commented on May 3, 2026

    @superuser404notfound
    Owner

    Sorry for not responding quicker! Thanks for your testing i will take a look into it!

  4. DrHurt commented on May 3, 2026

    @DrHurt
    ContributorAuthor

    No worries, sorry for tagging! Super impressed by your work. I think this will eventually become the gold standard for media playback on Apple devices replacing KSPlayer.

    Very well done!!!

  5. superuser404notfound commented on May 3, 2026

    @superuser404notfound
    Owner

    No worries, sorry for tagging! Super impressed by your work. I think this will eventually become the gold standard for media playback on Apple devices replacing KSPlayer.

    Very well done!!!

    Wow thanks a lot!! This project was started for my tvOS Jellyfin Player because all the existing engines wouldnt fit my needs or were to complicated to implement.

    I pushed a potential fix for the dolby vision stuff. HDR10+ is still an issue i have to look at. Could you please test this? I currently dont have a dv display :(

  6. DrHurt commented on May 3, 2026

    @DrHurt
    ContributorAuthor

    That was super fast. I'll test it once you push a new built to test flight (don't have the setup to build this).

  7. superuser404notfound commented on May 3, 2026

    @superuser404notfound
    Owner

    The fix is gonna be part of the 0.5.0 update, this may take some days until release. Thanks again for your testing, that was really helpful information!

  8. DrHurt commented on May 3, 2026

    @DrHurt
    ContributorAuthor

    HDR10+ probably needs kCMSampleAttachmentKey_HDR10PlusPerFrameData but we should wait until we test & iron out Dolby Vision before moving to HDR10+

    I'll keep an eye on TestFlight and let you know how it goes.

  9. DrHurt commented on May 5, 2026

    @DrHurt
    ContributorAuthor

    I see you’ve released 0.5.0 with potential fixes for DV & HDR10+ but it’s probably still awaiting Apple review.

    Looking forward to testing it and reporting back.

    One trick we use is incrementing build number without changing version number. That bypasses Apple review and gives testers instant access to beta builds for quicker feedback & debugging.

    We bump version only when releasing!

  10. superuser404notfound commented on May 6, 2026

    @superuser404notfound
    Owner

    0.5.0 is now live for testing!

  11. DrHurt commented on May 6, 2026

    @DrHurt
    ContributorAuthor

    Unfortunately got exact same results. P8 & HDR10+ fall back to HDR10, wrong colours with P5.

    First thought is whether gating on displaySupportsDolbyVision is actually working as expected (because Apple documentation says it’s deprecated) so it might be blocking the new pathway.

    I’ll try again after work and will manually change TV mode to DV to see if that changes anything.

    Might be worth removing gating for now for debugging purposes (another 0.5.0 build).

  12. superuser404notfound commented on May 6, 2026

    @superuser404notfound
    Owner

    Thanks for testing and the detailed analysis! Two follow-up changes just landed (engine c01cb15, Sodalite fee8c3e). Will be in the next TestFlight build.

    Two distinct root causes addressed:

    1. displaySupportsDolbyVision gate removed — your hypothesis was on point. AVPlayer.availableHDRModes is soft-deprecated on tvOS 26 and observed in third-party players to lag the HDMI HDR-mode handshake. We now always tag DV streams as dvh1 + dvcC whenever the codec params carry an AVDOVIDecoderConfigurationRecord, regardless of the gate. Profile 8.1 / 8.4 still play their backward-compatible base layer on non-DV TVs; Profile 5 has no compatible base so it'll still produce wrong colours on a non-DV sink, same as before.

    2. HDR10+ HEVC bitstream walker added — the HW (VideoToolbox) path was the bug here. FFmpeg only parses ITU-T T.35 SEI inside its own HEVC decoder, which we bypass entirely on the HW path. So AV_PKT_DATA_DYNAMIC_HDR10_PLUS on packets was empty for HEVC sources and our previous extraction returned nil. Now there's a manual NAL walker that parses PREFIX_SEI_NUT / SUFFIX_SEI_NUT, unescapes RBSP, finds payload_type 5 SEI matching the HDR10+ signature (country_code 0xB5 / terminal_provider 0x003C / oriented_code 0x0001 / application_identifier 4) and returns the T.35 payload starting at the country_code byte for kCMSampleAttachmentKey_HDR10PlusPerFrameData. SW path was already correct via AVFrame side data and is unchanged.

    Diagnostics added so the next test round leaves a clear trace:

    • [VideoDecoder] AVPlayer.availableHDRModes raw=N contains.dolbyVision=true|false on every stream open. Tells us what the deprecated API actually returns on your hardware.
    • [VideoDecoder] Dolby Vision detected: profile=N level=N rpu=N el=N bl=N compat=N → tagging as 'dvh1' with dvcC plus a hex dump of the 24-byte dvcC atom. Lets us cross-check the bit packing against MP4Box -info if needed.
    • [VideoDecoder] HEVC bitstream SEI walker found HDR10+ T.35 payload (N bytes) (one-shot per stream). Confirms the new HW-path extraction worked.
    • [Renderer] HDR10+ attachment count: N (last payload N bytes) at 1, 30, then every 600 frames. Proves the metadata is actually reaching the display layer.

    If you can grab a Console log during your next test (TV + Play/Pause for a screenshot is fine, idevicesyslog if you have a Mac), those four lines plus the visible TV behaviour should narrow down whatever remains in one round. Especially curious whether the gate logs contains.dolbyVision=true or =false on your TV.

    Thanks again!

  13. 108 remaining items

  14. superuser404notfound commented on May 13, 2026

    @superuser404notfound
    Owner

    Quick update: the issues from the previous post are fixed, the new pipeline is up on the device.

    Verified on Apple TV across two real Jellyfin sources (1440x1080 HEVC + AC-3, 1920x1080 H.264 + EAC3):

    • Initial playback: clean. Resume-from-position into mid-stream segments (seg-54, seg-60) lands the right bytes in the player.
    • Forward scrubs: clean across multiple jumps per session (seg-1 → seg-60 → seg-116, etc).
    • Backward scrubs: clean too. Cache window slides the right way on a back-jump, producer restarts at the requested index, AVPlayer gets bytes within ~350 ms.
    • A/V sync: holds across all of the above. No drift, no freeze, no chaos-after-a-few-seconds behaviour.

    The resume-jump deadlock was the single root cause behind the previous round's "HEVC freezes after 2 s" AND the "H.264 hangs after second scrub" symptoms. One bug, two presentations.

    Open polish items on my side:

    1. Scrub-restart latency. When the old producer's pump is in mid-mux at the moment of scrub, the restart blocks for up to ~800 ms before the pump notices the stop signal. Easy fix: have producer.stop() broadcast on the cache's condvar so the pump's awaitFetchHighWater returns immediately instead of waiting for its 1 s poll interval. Drops scrub-restart latency to a flat ~250 ms regardless of pump state.

    2. First-segment latency. Currently ~370 ms because hls_time = 6.0 and the producer has to demux 6 s of source before the first cut. Dropping to hls_time = 4.0 halves that and stays well within Apple's HLS Authoring Spec recommendation.

    Both are small. The hard part is done.

    I'll roll those in after one more day of soak-testing, and then move on to the codec expansion you offered to help with. Looking forward to the writeup.

  15. DrHurt commented on May 13, 2026

    @DrHurt
    ContributorAuthor

    With your permission, I’ll probably open a new thread for the codec stuff as this one has become a bit long.

    Also: thinking outloud but how would you feel about moving the AVPlayerLayer & related bits like matching dynamic range & frame rate from sodalite to aether so that the engine is self contained from file input to render surface.

    That way iOS/tvOS/macOS devs in the future can simply drop aether in, load a file and it just works.

  16. superuser404notfound commented on May 13, 2026

    @superuser404notfound
    Owner

    Yes please, separate thread for the codec work is the right call. This one has earned its retirement.

    And: yes, that direction is exactly where I want to take this. The engine already owns the render surface on the FFmpeg + VideoToolbox path (it hands the host an AVSampleBufferDisplayLayer), but the AVPlayer path leaks responsibility back to Sodalite: the host mounts the AVPlayerLayer, builds the AVDisplayCriteria, talks to AVDisplayManager for the HDMI mode handshake, and even decides when to fall back. That asymmetry is the main reason "drop aether in and play a file" isn't true yet on the native route.

    The plan is to fold all of that into the engine, then collapse to a single path:

    • one public surface, an AetherPlayerView (UIKit/AppKit + a SwiftUI wrapper) that hosts the active renderer
    • the engine owns the dynamic-range handshake end-to-end, building the CMVideoFormatDescription from the format it already detects (HDR10 / HDR10+ / HLG / DV with the correct dvh1 / hvc1 codec tag)
    • frame-rate matching driven by the actual stream rate from the demuxer, not a hardcoded 23.976
    • host honors a single boolean ("match content", off by default like Apple) and otherwise stays out of it
    • and after the AVPlayer surface lands, the aether sample-buffer path retires: every source flows through the muxer to fMP4 over loopback, including MP4 containers, so the engine is a pure format-agnostic feeder for AVPlayer with one path and predictable behavior

    Codec expansion (VP9 + AV1) lands on top of that, gated on real VTRegisterSupplementalVideoDecoderIfAvailable + VTIsHardwareDecodeSupported probes at engine init. Older silicon that can't AVPlayer-decode a codec gets a clear refusal instead of a silent software fallback.

    Looking forward to the writeup. The codec thread can land on a much tidier engine.

  17. DrHurt commented on May 13, 2026

    @DrHurt
    ContributorAuthor

    I have created a separate thread with containers and codecs to help Aether's HLS engine use the full capabilities of AVPlayer.

    Some thoughts after looking at recent changes:

    AV1 is only supported on devices with hardware decoding. There is no software fallback in AVPlayer.
    VP9 is only ever used on YouTube. Only Safari can decode it, and only inside webm containers. (my fault, sorry)

    I see you removed the ffmpeg/dav1d software decode layer (correct me if I'm wrong). I think a lot of users (especially with older devices) would want to have software decode for at least AV1 (and a small minority of users will want VP9 and older codecs).

    May I suggest, once Aether HLS + AVPlayer is stable, that you offer ffmpeg/dav1d as a self contained Aether "extension" that plugs into your new player view for devs that want to increase codec compatibility via software decoding.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions