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
953 stars 193 forks source link

AVDisplayCriteria from formatDescription not responds DV profile only HDR10 #633

Closed Alanko5 closed 10 months ago

Alanko5 commented 10 months ago

Describe the bug displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)

Printing description of formatDescription:
<CMVideoFormatDescription 0x2834f9b60 [0x236974b20]> {
    mediaType:'vide' 
    mediaSubType:'x420' 
    mediaSpecific: {
        codecType: 'x420'       dimensions: 3840 x 2160 
    } 
    extensions: {{
    CVBytesPerRow = 11524;
    CVImageBufferChromaLocationBottomField = Left;
    CVImageBufferChromaLocationTopField = Left;
    CVImageBufferColorPrimaries = "ITU_R_2020";
    CVImageBufferTransferFunction = "SMPTE_ST_2084_PQ";
    CVImageBufferYCbCrMatrix = "ITU_R_2020";
    Version = 2;
}}
}

To Reproduce starts video with DV tvOS switch TV to HDR

Platform (please complete the following information):

Screenshots

Snímka obrazovky 2023-11-13 o 19 29 59

<<<< AudioFormatDescription >>>> figAudioFormatDescriptionEnsureRichestDecodableLayout signalled err=-12718 (kCMFormatDescriptionError_ValueNotAvailable) (no formats in format list) at FigAudioFormatDescription.c:2148

(Fig) CMVideoFormatDescriptionCreate signalled err=-12710 (kFigFormatDescriptionError_InvalidParameter) (!codecType) at FigVideoFormatDescription.c:417

kingslay commented 10 months ago

不要用 AVDisplayCriteria(refreshRate: refreshRate, formatDescription。继续用我们原有的AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: dynamicRange.rawValue) 就可以了。目前formatDescription里面是没有dv信息,所以无法判断是dv

Alanko5 commented 10 months ago
Create criteria ni KS method not exist
kingslay commented 10 months ago

没有函数了。你换成这样写


   override func updateVideo(refreshRate: Float, isDovi: Bool, formatDescription: CMFormatDescription?) {
        #if os(tvOS) || os(xrOS)
        guard let displayManager = UIApplication.shared.windows.first?.avDisplayManager,
              displayManager.isDisplayCriteriaMatchingEnabled,
              !displayManager.isDisplayModeSwitchInProgress
        else {
            return
        }
        if let formatDescription {
            if KSOptions.displayCriteriaFormatDescriptionEnabled, #available(tvOS 17.0, *) {
                displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)
            } else {
                let dynamicRange = isDovi ? .dolbyVision : formatDescription.dynamicRange
                displayManager.preferredDisplayCriteria = AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: dynamicRange.rawValue)
            }
        }
        #endif
    }