diff --git a/iina/VideoView.swift b/iina/VideoView.swift index b6a288e2590..dc646e3d1f8 100644 --- a/iina/VideoView.swift +++ b/iina/VideoView.swift @@ -301,7 +301,20 @@ extension VideoView { return false; } - guard let primaries = mpv.getString(MPVProperty.videoParamsPrimaries), let gamma = mpv.getString(MPVProperty.videoParamsGamma) else { return false } + guard var primaries = mpv.getString(MPVProperty.videoParamsPrimaries), var gamma = mpv.getString(MPVProperty.videoParamsGamma) else { return false } + + // Because MPV won't check for mastering display metadata, we have to check it ourselves + // TODO: Supports multi-track video source. Maps MPV `player.info.vid` to FFMPEG `streamIndex` + if primaries == "bt.2020" && !player.info.isNetworkResource && player.info.videoTracks.count == 1 { + if let path = mpv.getString(MPVProperty.path), let colorspaceData = FFmpegController.getColorSpaceMetadata(forFile: path) { + if let _primaries = colorspaceData["primaries"] as? String { + primaries = _primaries + } + if let _gamma = colorspaceData["color-trc"] as? String { + gamma = _gamma + } + } + } var name: CFString? = nil; switch primaries {