kingslay / KSPlayer

A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, SwiftUI, support subtitles.
https://apps.apple.com/app/tracyplayer/id6450770064
GNU General Public License v3.0
933 stars 192 forks source link

Dolby Vision not detected #193

Closed jartas closed 2 years ago

jartas commented 2 years ago

Hi, when I play video with Dolby Vision, player not detected this layers and tv not switch on Dolby Vision

There is sample with DV:

https://iscc.site/DVProf5_UHD_Dolby_Atmos.mp4

Alanko5 commented 2 years ago

@cxfksword @kingslay

THX for fix: #268 but it's still not correct. please try it out.

If start video with dual layer (not profile 8/5) Dolby Vision, then you detection DV is work (even if it doesn't have the right color).

Now I test this videos: https://developer.dolby.com/tools-media/sample-media/video-streams/dolby-vision-streams/

If start video with profile 5 (START time is too longer) http://media.developer.dolby.com/DolbyVision_Atmos/mp4/iOS_P5_GlassBlowing2_3840x2160%4059.94fps_15200kbps.mp4

Snímka obrazovky 2022-08-05 o 11 07 08

KSPlayer not detect yCbCrMatrix, colorPrimaries and DolbyVision

if start video with profile 8.1 (START time is OK) http://media.developer.dolby.com/DolbyVision_Atmos/mp4/P81_GlassBlowing2_3840x2160%4059.94fps_15200kbps_fmp4.mp4

Snímka obrazovky 2022-08-05 o 11 05 29

KSPlayer not detect DolbyVision

kingslay commented 2 years ago

P81_GlassBlowing2_3840x2160@59.94fps_15200kbps_fmp4.mp4 is not DV

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/kintan/Downloads/P81_GlassBlowing2_3840x2160@59.94fps_15200kbps_fmp4.mp4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: mp42isomiso5 creation_time : 2020-10-06T22:55:34.000000Z Duration: 00:02:58.11, start: 0.000000, bitrate: 15520 kb/s Stream #0:00x1: Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 15138 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default) Metadata: handler_name : Bento4 Video Handler vendor_id : [0][0][0][0] encoder : HEVC Coding Side data: DOVI configuration record: version: 1.0, profile: 8, level: 9, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 1 Stream #0:10x2: Audio: eac3 (ec-3 / 0x332D6365), 48000 Hz, 5.1(side), fltp, 640 kb/s (default) Metadata: handler_name : Bento4 Sound Handler vendor_id : [0][0][0][0] Side data: audio service type: main

Alanko5 commented 2 years ago

HEVC is a recently established compression standard that supports larger frame sizes (including 8K), HDR10, and Dolby Vision 8.4 metadata for high-dynamic-range video. Dolby Vision 8.4 is a format designed to optimize HDR content for Apple devices.

Alanko5 commented 2 years ago

P81_GlassBlowing2_3840x2160@59.94fps_15200kbps_fmp4.mp4 is not DV DOVI configuration record: version: 1.0, profile: 8, level: 9, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 1

Is official Dobly studios page, this ist a sampe stream! Check your output DOVI is a DOlbyVIsion with profil 8 wtihout EL layer only with BL layer....

Alanko5 commented 2 years ago

For example, it can be solved as follows:

Extend:

public protocol MediaPlayerTrack {
#if os(tvOS)
    var dynamicRange: MPTDynamicRange { get }
#endif

Add enum:

#if os(tvOS)
public enum MPTDynamicRange {
    case SDR
    case HDR
    case HLG
    case DoVi
}
#endif

Add into AssetTrack init this:

#if os(tvOS)
        if (av_stream_get_side_data(stream, AV_PKT_DATA_DOVI_CONF, nil) != nil) {
            dynamicRange = .DoVi
        } else if (stream.pointee.codecpar.pointee.color_trc == AVCOL_TRC_SMPTE2084) {
            dynamicRange = .HDR
        } else if (stream.pointee.codecpar.pointee.color_trc == AVCOL_TRC_ARIB_STD_B67) {
            dynamicRange = .HLG
            // file could be SMPTE2086 which FFmpeg currently returns as unknown
            // so use the presence of static metadata to detect it
        } else if (av_stream_get_side_data(stream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, nil) != nil) {
            dynamicRange = .HDR
        } else {
            dynamicRange = .SDR
        }
#endif

Add into AVMediaPlayerTrack init this:

#if os(tvOS)
        if let criteria =  track.assetTrack?.asset?.preferredDisplayCriteria {
            if criteria.videoDynamicRange == 0 {
                dynamicRange = .SDR
            } else if criteria.videoDynamicRange == 2 {
                dynamicRange = .HDR
            } else if criteria.videoDynamicRange == 5 {
                dynamicRange = .DoVi
            }
        } else {
            dynamicRange = .SDR
        }
#endif