Skip to content

Some Dolby Vision MKV files not playing #158

Closed

Description

@ptaru

VideoToolbox can natively decode HEVC Profile 5 Dolby Vision and pass on the proper RPU/metadata but it needs special handling with MKV files. I haven't had the time to look into your VideoDecoder implementation (or how the Media Extensions API works) but from experience you basically need to reconstruct the extradata when missing and properly pass on the dvcC blob.

Activity

  1. ptaru commented on Feb 12, 2026

    @ptaru
    Author

    I have a reasonably robust implementation of demuxing mkv -> directly passing sample buffers to AVSBDL in https://github.com/ptaru/VidCore that you're free to use. License is LGPL which should be compatible with QLVideo's GPL.

  2. Marginal commented on Feb 12, 2026

    @Marginal
    Owner

    I'm creating sample description atoms for VideoToolbox here, but not for dvcC.

    I'll take a look at your code, thanks. Do you have any links to documentation on what a dvcC atom should contain?

  3. ptaru commented on Feb 12, 2026

    @ptaru
    Author

    There's no good documentation since it's proprietary. I just studied libdovi code and inspected what AVAssetReader does with MP4 files. Basic implementation looks like this:

    func makeDVCC(from doviConfig: Data) -> Data? {
        guard doviConfig.count >= 8 else { return nil }
    
        let b = [UInt8](doviConfig)
        let dvVersionMajor = b[0]
        let dvVersionMinor = b[1]
        let dvProfile = b[2]
        let dvLevel = b[3]
        let rpuPresentFlag = b[4]
        let elPresentFlag = b[5]
        let blPresentFlag = b[6]
        let dvBlSignalCompatibilityId = b[7]
    
        // Match VidCore behavior: do not emit dvcC for Profile 7 as VideoToolbox breaks with dual-layer files.
        if dvProfile == 7 { return nil }
    
        var dvcC = [UInt8](repeating: 0, count: 24)
        dvcC[0] = dvVersionMajor
        dvcC[1] = dvVersionMinor
        dvcC[2] = (dvProfile << 1) | ((dvLevel >> 5) & 0x01)
        dvcC[3] =
            ((dvLevel & 0x1F) << 3) |
            ((rpuPresentFlag & 0x01) << 2) |
            ((elPresentFlag & 0x01) << 1) |
            (blPresentFlag & 0x01)
        dvcC[4] = (dvBlSignalCompatibilityId & 0x0F) << 4
    
        return Data(dvcC)
    }

    ie. you allocate a 24-byte dvcC payload and fill bytes 0...4 with parsed DoVi fields, rest remain zeroed. FFmpeg gives you AV_PKT_DATA_DOVI_CONF.

  4. Marginal commented on Feb 13, 2026

    @Marginal
    Owner

    Thanks for the test files. After building a "dvvC" or "dvcC" atom from AVDOVIDecoderConfigurationRecord AVFoundation+VideoToolbox render the Dolby files fine.
    However FFmpeg doesn't see any Dolby Vision data in your test file (AVCodecParameters doesn't contain any AVDOVIDecoderConfigurationRecord side data), and I can't see any other way to tell this apart from vanilla HEVC. VideoToolbox refuses to render it as plain HEVC. How was this encoded?
    (I'm reluctant to add libplacebo as a dependency because it drags in so many other dependencies. As long as I can get VideoToolbox to do the decode I think I can avoid it).

  5. ptaru commented on Feb 13, 2026

    @ptaru
    Author

    I have no idea how it was encoded, it was found on the high seas (which is why I deleted the earlier comment). I just clipped 10 seconds out a random movie. I can assure you that you absolutely do not need libplacebo. I wrangled my own code into a demux-only Media Extension and I can play the file properly.

    Step 1 here is the important bit. That file's HEVC parameter sets are in-band rather than in the container header so in my code I resort to synthesising the hvcC atom.

    Image
  6. added a commit that references this issue on Feb 14, 2026
    f7750d5
  7. added a commit that references this issue on Feb 14, 2026
    7b8534d
  8. Marginal commented on Feb 16, 2026

    @Marginal
    Owner

    Added support for Dolby Vision in Matroska/HEVC in Release 3.01. This only works for well-formed files that contain a AVDOVIDecoderConfigurationRecord in FFmpeg. (I tried synthesizing this if absent from per-frame metadata but was unsuccessful).
    Thanks @ptaru for your help.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions