KSPlayer icon indicating copy to clipboard operation
KSPlayer copied to clipboard

Dolby vision Issue

Open Alanko5 opened this issue 3 years ago • 8 comments

HDR video if use one layer is good. (https://sylvan.apple.com/Aerials/2x/Videos/LA_A006_C008_2K_HDR_HEVC.mov -> is playing correctly)

But if DV use 2 layers then KSplayer not show correctly: https://user-images.githubusercontent.com/71501260/114447418-ae9e9d00-9bd2-11eb-87cd-75ca210165c3.mov

Corect visualisation: https://sheri.eu/iscc/IMG_1091.MOV

sample: https://sheri.eu/iscc/dolby-vision-amaze-(dolby-vision).mp4

KSPlayer track info: video name: und bitRate: 18057854 fps: 23.976025 bitDepth: 10 colorPrimaries: colorPrimaries: yCbCrMatrix: codecType: ehvd

Alanko5 avatar Apr 12 '21 19:04 Alanko5

@kingslay please, is it possible to solve this problem?

for codecs: hev1, (edvh/dvhe), (hvcC+dvcC) for profiles: 5 and 7

Alanko5 avatar Apr 28 '21 10:04 Alanko5

Is AVSampleBufferDisplayLayer the layer? What player did you use to play it. I used vlc, which is the same as ksplayer

kingslay avatar May 16 '21 14:05 kingslay

I use KSPlayer on AppleTV. KSPlayer not detect colorPrimaries: yCbCrMatrix:

Dolby Vision have single video layer and dual video layer:

http://bilder.hifi-forum.de/max/867239/dolby-vision-single-dual-layer_850774.png

This example use dynamic hdr metadata (Dolby Vision) and use dual (video) layer for playing. https://sheri.eu/iscc/dolby-vision-amaze-(dolby-vision).mp4

VLCKit not support HDR formats. VLCKit convert HDR to SDR. VLCKit not support DV metadata for playing.

Alanko5 avatar May 18 '21 13:05 Alanko5

This can be done only if ffmpeg supports Dolby Vision dual video layer

kingslay avatar May 20 '21 13:05 kingslay

https://github.com/staxrip/staxrip/wiki/Encoding-Dolby-Vision-with-StaxRip-using-x265

https://www.mail-archive.com/[email protected]/msg126853.html

Alanko5 avatar Nov 08 '21 17:11 Alanko5

Dual layer dollby vision log

Infuse (use ffmpeg) support dual layer DolbyVision.

but apple tv not support. 😢

Alanko5 avatar Jan 06 '22 22:01 Alanko5

@kingslay DV FEL (profile 7) Include HDR layer and dynamic metadata layer.

Can you please at least play only HDR layer?

Alanko5 avatar Jan 07 '22 14:01 Alanko5

Detection for DolbyVision stream

https://github.com/MrMC/mrmc/blob/5a8e460b2aec44f03eb9604cbd7681d4277dbb81/xbmc/platform/darwin/DarwinVideoUtils.mm

case HEVC_NAL_UNSPECIFIED_63:
        // The dolby vision enhancement layer doesn't actually use NAL units 63 and 62,
        // it uses a special syntax that uses 0x7E01 and 0x7C01 as separator that makes
        // the Dolby Extension Layer (EL) appear as unspecified/unused NAL units (62 and 63),
        // but the actual NAL information starts after that extra header.
        if (nal_type_full == 0x7C01)
        {
          CLog::Log(LOGDEBUG, "%s - frame(%llu), dolby vision enhancement layer of 0x7C01 with size(%d)",
            __FUNCTION__, frameCount, nal_size);
        }
        else if (nal_type_full == 0x7E01)
          CLog::Log(LOGDEBUG, "%s - frame(%llu), dolby vision enhancement layer of 0x7E01 with size(%d)",
            __FUNCTION__, frameCount, nal_size);
        else
        {
          CLog::Log(LOGDEBUG, "%s - frame(%llu), HEVC_NAL_UNSPECIFIED_62/63 with size(%d)",
            __FUNCTION__, frameCount, nal_size);
        }
        break;

https://github.com/MrMC/mrmc/commit/5e6d1dc9e65fc64d1af9d320fcdbfa80e662f488

        // missing in ffmpeg for DolbyVison (dvhe)
        if (pStream->codec->codec_id == AV_CODEC_ID_NONE)
        {
          if (pStream->codec->codec_tag == MKTAG('d','v','h','e'))
          {
            pStream->codec->codec_id = AV_CODEC_ID_HEVC;
            CLog::Log(LOGERROR, "%s - dvhe, detected forcing AV_CODEC_ID_HEVC", __FUNCTION__);
          }
        }
        // overlap in ffmpeg of DV Video and DolbyVison (dvh1)
        // hack force it to AV_CODEC_ID_HEVC, should fix ffmpeg.
        if (pStream->codec->codec_id == AV_CODEC_ID_DVVIDEO)
        {
          if (pStream->codec->codec_tag == MKTAG('d','v','h','1'))
          {
              pStream->codec->codec_id = AV_CODEC_ID_HEVC;
              CLog::Log(LOGERROR, "%s - AV_CODEC_ID_DVVIDEO detected, forcing AV_CODEC_ID_HEVC", __FUNCTION__);
          }
        }

https://github.com/MrMC/mrmc/blob/5a8e460b2aec44f03eb9604cbd7681d4277dbb81/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp

        if (!CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVIDEOTOOLBOX_HEVC_HDR) &&
             (hints.profile == FF_PROFILE_HEVC_MAIN_10 ||
              hints.profile == FF_PROFILE_HEVC_REXT ||
              hints.codec_tag == MKTAG('d','v','h','1') ||
              hints.codec_tag == MKTAG('d','v','h','e') ||
              hints.codec_tag == MKTAG('D','O','V','I')))
        {
          // if bt2020+, kick it to AVFoundataion
          if (hints.colortransfer >= AVCOL_TRC_SMPTE2084)
            return false;
          // only AVFoundataion can handle DolbyVision
          if (hints.codec_tag == MKTAG('d','v','h','1') ||
              hints.codec_tag == MKTAG('d','v','h','e') ||
              hints.codec_tag == MKTAG('D','O','V','I'))
            return false;
        }

Alanko5 avatar Apr 18 '22 18:04 Alanko5