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

Dolby Vision no longer works #571

Closed UnknownCoder807 closed 11 months ago

UnknownCoder807 commented 11 months ago

Since the change to the HDR/SDR detection code, Dolby Vision is no longer correctly detected on tvOS.

I don't have a DV Tele or any DV content so I can't test but I am getting multiple reports.

kingslay commented 11 months ago

那把KSOptions.displayCriteriaMatchingEnabled 设置为false是不是就不会有问题了

UnknownCoder807 commented 11 months ago

If I disable that setting then no video will be detected as HDR/DV.

Previously both HDR and DV was detected perfectly. Now only HDR is.

kingslay commented 11 months ago

重载的preferredDisplayCriteria 方法的实现方法你是怎么写的呢?反馈不能显示DV的用户是用tvOS 16还是tvOS17呢?

UnknownCoder807 commented 11 months ago

I use the exact same code in the override as the function is. Except I added an if statement to check if user has come from live or vod - so I can disable hdr on the fly. I can’t post code as I am away from computer.

Dolby vision is detected as HDR. Using tvOS 17

kingslay commented 11 months ago

那可能是tvOS 17的方法判断不准,所以不要用 if #available(tvOS 17.0, *) { if let formatDescription = track.formatDescription { return AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription) } else { return nil } }

还是继续用 let videoDynamicRange = track.dynamicRange(self).rawValue return AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: videoDynamicRange) 来判断吧

cdguy commented 11 months ago

since your commit about dynamic range https://github.com/kingslay/KSPlayer/commit/485f9952bc0985d0eea043cc9b7cfdd41b41cb7e all DV content are forced to HDR

cdguy commented 11 months ago

sorry @kingslay the issue started after this discussion: https://github.com/kingslay/KSPlayer/discussions/563

the "old code" would work perfectly

cdguy commented 11 months ago

you can also have a look at this one too @kingslay

https://github.com/kingslay/KSPlayer/commit/4c27f4c55551e089d5e083a278432949fb19cce9

kingslay commented 11 months ago

那就是AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription) 这个方法是不支持DV的。那我先默认不开启AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)

cdguy commented 11 months ago

thank you I will try,

also can you please update the testflight tracy player?

thank you

@kingslay

UnknownCoder807 commented 11 months ago

I don't know why, but since you renamed the settings to toggle HDR/SDR my code no longer works.

It probably never worked before, because you were setting displayCriteriaMatchingEnabled to true and now you set to false.

I set

myOptions.contentMatchingLive = true
KSOptions.displayCriteriaFormatDescriptionEnabled = true

and inside my myOptions() class, displayCriteriaFormatDescriptionEnabled is always false

public class meOptions: KSOptions {
    var contentMatchingLive = false

    #if os(tvOS)
    override open func preferredDisplayCriteria(track: some MediaPlayerTrack) -> AVDisplayCriteria? {
            if contentMatchingLive {
                let refreshRate = track.nominalFrameRate
                if KSOptions.displayCriteriaFormatDescriptionEnabled, let formatDescription = track.formatDescription, #available(tvOS 17.0, *) {
                    return AVDisplayCriteria(refreshRate: refreshRate, formatDescription: formatDescription)
                }
        }

        return nil
    }
}
kingslay commented 11 months ago

你看我最新的提交 我改了 你试下

UnknownCoder807 commented 11 months ago

Already using the latest code.

No matter where I set displayCriteriaFormatDescriptionEnabled to true, it is always false in the override for the display criteria.

kingslay commented 11 months ago

displayCriteriaFormatDescriptionEnabled 要设置为false。tvOS17那个新的api是不兼容dv格式的。所以还是要用老的方式来设置

UnknownCoder807 commented 11 months ago

ok, I understand about DV. but toggling HDR/SDR switching via the old displayCriteriaMatchingEnabled switch you added worked 100%. You have renamed it to displayCriteriaFormatDescriptionEnabled and set it to false by default.

It is not possible to set this to true. In the preferredDisplayCriteria(track: some MediaPlayerTrack) -> AVDisplayCriteria? function it is always false. it can't be changed to true.

This affects normal HDR as well. there is no switching possible now because displayCriteriaFormatDescriptionEnabled cannot be set to true, ever.

kingslay commented 11 months ago

跟这个开关没有关系。你只要改成用 AVDisplayCriteria(refreshRate: refreshRate, videoDynamicRange: videoDynamicRange) 这个初始化方法来创建 AVDisplayCriteria。 你重载的方法里面 甚至可以不用判断那个开关。 现在的问题是tvos17新的api初始化方法是有问题的话 所以我们要用之前老的初始化方法。 我还保留这个开关是期待后续Apple可以修复这个问题 然后到时就可以把这个开关打开了。

UnknownCoder807 commented 11 months ago

ok, thanks for the information. I will use the other code and this should solve dolby vision?

edge261 commented 11 months ago

Now this opens again a problem I thought was solved but was a bug instead:

many HDR streams use HLG instead of HDR10, and this code output Dolby Vision.

Thing is, in tvOS, HDR HLG is supposed to be output as HDR10, not Dolby Vision.

https://community.firecore.com/t/hlg-on-3rd-gen-atv-4k/39538/16 https://www.flatpanelshd.com/review.php?subaction=showfull&id=1668063491

kingslay commented 11 months ago

Now this opens again a problem I thought was solved but was a bug instead:

many HDR streams use HLG instead of HDR10, and this code output Dolby Vision.

Thing is, in tvOS, HDR HLG is supposed to be output as HDR10, not Dolby Vision.

https://community.firecore.com/t/hlg-on-3rd-gen-atv-4k/39538/16 https://www.flatpanelshd.com/review.php?subaction=showfull&id=1668063491

你是否可以提供下对应的HDR 、HDR10、 Dolby Vision的视频小片段吗?我看下是否有一些视频属性可以把这三个区分开。

edge261 commented 11 months ago

Now this opens again a problem I thought was solved but was a bug instead: many HDR streams use HLG instead of HDR10, and this code output Dolby Vision. Thing is, in tvOS, HDR HLG is supposed to be output as HDR10, not Dolby Vision. https://community.firecore.com/t/hlg-on-3rd-gen-atv-4k/39538/16 https://www.flatpanelshd.com/review.php?subaction=showfull&id=1668063491

Can you provide video clips corresponding to HDR, HDR10, and Dolby Vision? I'll see if there are some video attributes that distinguish these three.

Sure thing.

HLG HDR: https://4kmedia.org/travelxp-4k-hdr-hlg-sample/ HDR10: https://4kmedia.org/life-untouched-hdr-uhd-4k-demo/ HDR10+: https://ff.de/hdr10plus-metadata-test/ Dolby Vision: https://4kmedia.org/lg-earth-dolby-vision-uhd-4k-demo/

Also, here's more info about the attributes for HLG HDR videos: http://forum.doom9.org/archive/index.php/t-175533.html

basically, for HLG HDR you must check for the transfer characteristics.

edit: added hdr10+ sample

kingslay commented 11 months ago

@edge261 我试了下 HLG HDR: https://4kmedia.org/travelxp-4k-hdr-hlg-sample/ 识别为 HLG HDR10: https://4kmedia.org/life-untouched-hdr-uhd-4k-demo/ 识别为HDR10 HDR10+: https://ff.de/hdr10plus-metadata-test/。 识别为HDR10 Dolby Vision: https://4kmedia.org/lg-earth-dolby-vision-uhd-4k-demo/ 识别为dolbyVision 这样是符合预期的吧。

edge261 commented 11 months ago

@kingslay then why the HLG streams i'm testing are triggering Dolby Vision on my TV instead of the standard HDR10 mode?

I can send you in a email the link of the stream I'm trying to watch.