New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utilise macOS HDR/EDR functionality #7341
Comments
i assume it's a duplicate of #4248. |
It seems that they are separate issues. The difference in #4248 is subtle while it's significant in my case. I believe Quicktime Player is able to utilize a new feature of Catalina which increases the brightness of the screen when playing HDR content. |
quicktime and mpv look 'identically' if i use |
Sorry, forget about my setting. iina/iina#2705 has a better explanation of this situation. |
so if you play both at the same time, in quicktime and mpv, they looks the 'same' brightness wise? since quicktime increases the screen brightness? if the screen brightness really increased |
Nope. Only the Quicktime window would have higher brightness, although I'm not quite sure how that's achieved. Wonder if that's possible for mpv to adopt this function. |
if it's not the screen but only that window, i can only think about a few possibilities. though i am not sure how this would fit into mpv's render pipeline.
i would need to test this and maybe it would be helpful to know what those values output on your end. |
I would like to help but I have no idea how to. Could you tell me how can I get these values? |
i will have to write some small script for that. maybe next week when i am on vacation. |
if you want you can test following script and paste me the output here: call like:
|
Thanks for your script. Here's my result: When the video I mentioned is played with mpv / When nothing is played: Played with Quicktime: |
on a side note, i am still on 10.14 so i only get the last value. in both cases only mpv is playing or only quicktime is playing:
so i guess it's most likely the reason why quicktime can be brighter (probably twice as much). |
Great. Now we know what causes the difference. Is there a way to implement this function? I guess Quicktime has done more than simply multiplying the brightness by 2.0. There is guessing that Quicktime utilize a system built-in tone mapping method. If so, would it be possible to adopt that? Or modify our own tone mapping to achieve similar effect? |
like i said, i am not sure how this would fit into mpv's render pipeline (yet). no we can't use the macOS tone mapping since we do our own, and yes quicktime most likely uses the system tone mapping since Apple provides a public API for that. those values only remotely have something to do with tone mapping per se. note those values are called Extended Dynamic Range (EDR) and not HDR. this can even be helpful for none HDR content, in the case i understand everything correctly so far. i am writing up a new test case. |
Got it. Quicktime activates EDR when playing HDR videos, that's why I thought it's related to tone mapping. I'll WIP and see if I could help more. |
i made a second test: call like:
you can quit the script on the terminal with CTRL+C. it should spawn two windows with 4 rectangles. 2 white rectangles, 1 gray and 1 black. on the left window both white rectangles should look the same. on the right window both white rectangles should be distinguishable. the bottom one should be the brighter one. also please post the terminal output (without the deprecation warning) and possibly a screenshot. should look like this (on your screenshot the right white rectangles should be distinguishable):
|
Wow, you're fast! Here's what I got:
The screenshots look the same, but the bottom left rectangle in EDR activated window is actually brighter. |
okay, so i at least got the right switch how to trigger the increase of the EDR value. it makes sense that it gradual increases the value, an abrupt value change would most likely look weird. you can test the final value with the first script i posted, if you want. i guess the screenshot represents exactly what you see on your screen, eg you couldn't see a difference between the two white rectangles? which is too bad and i need to look into it a bit more. on a side note, how does the white rectangle compare to the white rectangle in the test clip you posted when played back in quicktime? is it also less bright? |
okay i updated my script here https://gist.github.com/Akemi/185d83afbef47c0c8e0add2a3c99b6d2 i additionally set the wantsExtendedDynamicRangeOpenGLSurface of the view. maybe that makes it work properly, if it didn't already. would be nice if you could try again and let me know you findings, terminal output etc. |
I tried the first script. When I manually toggled system brightness to maximum, the final value was 1.6666666269302368. Other than that, it was 2.0.
The second script works! I could see the difference between the two white rectangles on my screen when EDR activated. They only look the same in the screenshot. (My poor English just betrayed me.) Still, I tried the third script and here's the result:
|
that's great. it wasn't your fault, i didn't see you write something beneath the screenshot that answered my question. so everything works as expected. now i only need to find out how to integrate that into mpv itself. thanks for testing. [edit] |
since they use libmpv and most likely one of the opengl layers flavours they can do whatever they want and use the OS'/layers hdr capabilities, similar to this PR #8485. though i think i explained it somewhere on a different open issue or a PR. |
What is lacking in that PR? It works well IMO. |
that's what the PR says in my first comment. nothing changes on the reasons why, it's basically untested. |
By default utilises the color space of the screen on which the window is located. If a specific value is defined, it will be instead be utilised. Depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation is used. Fixes mpv-player#7341
By default utilises the color space of the screen on which the window is located. If a specific value is defined, it will be instead be utilised. Depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation is used. Fixes mpv-player#7341
By default utilises the color space of the screen on which the window is located. If a specific value is defined, it will be instead be utilised. Depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation is used. Fixes mpv-player#7341
@anastasiuspernat @Robot-DaneelOlivaw |
is this still something we need or want? my reasoning for asking: with the recent merge of the vulkan macOS backend for gpu(-next) (and making it default) this is already included with implementing this feature, or rather merging #8485, will not work in the vulkan case, since it will interfere with libplacebo/vulkan/moltenvk and actually breaks HDR output. so it shouldn't be added to the metal layer. that would only leave the old opengl cocoa-cb backend that is more or less deprecated. i could cleanup my PR and add it to cocoa-cb, though it is more or less just a makeshift solution and will never be as good/automatic as |
@Akemi I am sorry but I am not familiar with a lot of things that you said. I am still wondering, does mpv work with HDR on macOS as of now or not? |
with |
@Robot-DaneelOlivaw If it is not stable yet, do you believe it's a good idea to close the issue right now? |
this issue is about utilising the macOS 'HDR' capabilities, which is the case. a feature request should be closed when the feature was/is implemented. any kind of issue that arises after the initialise feature merge, should be reported with a new issue. @Robot-DaneelOlivaw basically i fixed the flickering yesterday with 6016423 i believe you are using an older build. i believe your expectation to have similar tone-mapping with and without hint is rather unexpected. anyway i didn't look into all the HDR stuff yet, though we have various also on i side note, you can get nightly app bundle builds on PRs (#13651 (comment) PR that fixed the flicker) and from master (#13085 (comment) the linked comment explains where to find them and the comment after that hast direct links to the latest master build). so you can try fixes without building mpv yourself. |
@Akemi Thanks. I've tested the master build and it indeed fixes the flicker. As of tone-mapping, I also compared the results with Quicktime Player and
Do we still have such use case, a macOS environment that doesn't have MoltenVK support but needs HDR playback capability? I'd say unless people specifically ask for this, there is no need to spend time on it. |
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
i decided to add the HDR/EDR support to the old cocoa-cb/libmpv/opengl backend after all (see PR #14017). reasons are:
|
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes mpv-player#7341
by default utilises the color space of the screen on which the window is located. if a specific value is defined, it will instead be utilised. depending on the chosen color space the macOS EDR (HDR) support is activated and that OS's transformation (tone mapping) is used. Fixes #7341
Thank you Akemi. Issue closed. |
Edit: To those who wonder what EDR is, here's a brief explanation: Apple’s “EDR” Brings High Dynamic Range to Non-HDR Displays
I was testing Quicktime Player and mpv 0.31.0 the other day on my 2017 13" Macbook Pro running macOS Catalina 10.15.2. The material I've been using is an HDR video which is linked below.
https://mdt6.com/MDTTVTESTBETA082HEVC10BIT2020.mp4
At 00:00:08, the video displays three rectangles with different luminance. According to the source (in Chinese unfortunately), the bottom one is 100 nits, the middle one is 350 nits while the top one being maximum of the screen.
With the default config
tone-mappinng=hable
, mpv is able to reveal the difference among three rectangles as below.However, Quicktime Player has significantly different behaviour. The rectangle on the top is brighter than mpv, even much brighter than a normal pure white picture (the screenshot below couldn't reproduce what's on the screen). If I manually turn up the brightness, the gap closes up. It seems that Quicktime Player is able to utilize more luminance of the screen than mpv, even though Macbook Pro only has an SDR one built-in.
My expectation is to see the relatively "correct" luminance and colour within the capability of my screen. If I remember correctly, the config should be
tone-mapping=clip tone-mapping-param=1.0
andtarget-peak
to be the brightness of my monitor. But with this setting, mpv still couldn't reach the brightness of Quicktime Player. Maybe the latter could automatically use the maximum brightness of the screen?I'm wondering if they are treating luminance in fundamentally different ways. But I don't have a clue. Hope I could find an answer here.
The text was updated successfully, but these errors were encountered: