如何在 Swift 中判断视频是否为 HDR?

How to tell if a video is HDR or not in Swift?

我需要检测视频是否为 HDR,并在此基础上做出决定。我正在使用 AVKit。 有什么办法可以区分。 谢谢

简单而精确:

var isHdrVideo = false
    let pVideoTrack = AVAsset(url: URL(fileURLWithPath: assetURL!))
    if #available(iOS 14.0, *) {
        let tracks = pVideoTrack.tracks(withMediaCharacteristic: .containsHDRVideo)
        for track in tracks{
            isHdrVideo = track.hasMediaCharacteristic(.containsHDRVideo)
            if(isHdrVideo){
                break
            }
        }
    }