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
[WIP] mac: add support to set color space for layer and macOS transformation (EDR/HDR) #8485
Conversation
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
@Akemi any progress on this? |
it's basically done, just needs some clean ups. though i am not able to test it because of the lack of the proper hardware (and software). i programmed it the way i think it's done but it still needs proper testing. especially the old case of none HDR and if still looks like it is supposed to with the extended flags set to true by default. |
I built and tested it with some SDR and HDR videos. SDR videos work as intended.
The settings are a bit confusing. I'm supposed to choose color primaries and transfer characteristics according to the video. But most HDR videos are usually BT.2020 PQ, which is not provided because its range is above 1.0. And Here are Mediainfo and log files, hope that these simple tests could help: HDR Mediainfo
HDR log file
SDR Mediainfo
SDR log file
|
otherwise, the default should always be the profile of the display because otherwise it will break everything else or rather the previous default case. also see the other PR for some explanations. though |
Thanks for you explanation. If |
the option is analogue not all of its functionality. if apple doesn't support it the way we need it, there is no way we can change that. yes, if i remember correctly we can also automatically set those option according to output-csp option, but that needs more changes in the libmpv api. though i already said that in my comment above or at leats implied. it should be done at a different point of time. i don't see a reason trying to add that now, if in the long run the whole thing might be useless. test first, gather some experience with it and get QOL changes later.
|
If there's no issues can someone merge this in, would be really nice to have this fixed so that media players that use mpv like iina can properly support HDR on MacOS |
no it can't be merged. the PR is not properly tested and it still needs cleaning up. also iina, or other media players, can't profit from this. they have to implement this themselves. |
@Akemi what would constitute proper testing? I’m happy to do some testing if it’s something I can do. |
see my comments above, for example #8485 (comment). if possible i would like to test it myself properly, but who knows when or if i get a new mac. |
It works fine for me. I used "Sony Bravia OLED 4K Demo.mp4" to test it,it perform the same or even better than QuickTime. IMG_6319.mp4When i set the maximum brightness or use the screenshot, you can see some different, but i don't know it is a problem or not. Here is my config to trigger HDR automatically:
Also can use input config to manually trigger it:
|
you cannot open quicktime and mpv at the same time and compare. quicktime sets the same/similar settings that influence the whole system. if you have both open at the same time you don't know if quicktime set those correctly or mpv. |
Would this allow for Dolby Vision support too? |
Dolby Vision forwarding to the display? Or Dolby Vision decoding in mpv? |
I mean I just have an mp4/mkv which has dolby vision content. I want it to play on the MacBook pro. Currently they look greenish purplish on mpv with 0 config. |
For that you need to wait for https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=5581 to be merged |
If it's profile 5 (it almost definitely is since the color space is different - this is the hue you're talking about), you can use Subler to convert it to an mp4 and then play it directly through Quicktime.
@haasn Do you know if there is there an easy way to tell when patches are merged into the master branch? Hard to tell looking at the website. Otherwise, is there an easy way to apply the patches locally and build it, besides applying each patch manually? |
The file I am trying to play is a mp4 dvhe.05.06 having dvhe as codec id with no hdr10 fallback. So I guess its profile 5. QuickTime only opens this file as audio though. mpv, iina... plays it having a greenish/purplish hue |
The issue is the fourCC tag, it's dvhe, not dvh1. Apple only supports dvhe via HLS. You can use https://github.com/rixtox/mp4dovi or Subler (just open it and resave it, make sure to set audio to passthru) to change it. |
I have no clue. I hate patchwork myself. I pushed my branch to https://github.com/haasn/FFmpeg/tree/dovi_reshaping But, to get this working in mpv, you also need the corresponding patches for libplacebo and mpv, which I will submit as soon as the above is merged. If you're really dedicated to testing it, ask @cyanreg, who I think has a patch for mpv already written? |
Thanks! I appreciate it. My goal is really just to be able to convert w/ffmpeg profile 5 mkv to mp4's with quicktime compatibility. Right now ffmpeg master doesn't recognize dolby vision in the mkv's, and doesn't support the dvh1 tag in mp4's. |
Compile the FFmpeg branch I linked against this branch of libplacebo and you should be able to use (And probably whatever video codec settings you want to encode with) |
Seems to work but I have to use both the tools you mentioned. I don't know if I am using them wrong. I am running the mp4dovi on the file, then if I try to open with QuickTime it still doesn't work. I open it with subler click on something then hit (CMD+S) to save. After that it works with QuickTime. However I was hoping for an explanation of what's happening. I am not very knowledgeable with these stuff and wondering if instead of doing this hacky thing there is some ffmpeg command that would do the same thing. |
Thanks for the great PR. But, as @Robot-DaneelOlivaw said above, the luminance looks a bit off. |
hi, any updates for HDR fuction, since OpenGL is completely deprecated by Apple |
i still don't have a working mac anymore and my PRs are on hold till i can get a new one. |
I can help to the test, M2 mini + external OLED monitor I confim the colorspace aproch is working, setting target colorspace to itur2100PQ, (displayP3_PQ gives wrong color) here is my setting vo=libmpv [HDR_PQ] Issue is wrong white point, i attached a comparison , the highlights of MPV are over exposed, and grey level is incorrect as well |
see my comment here #7341 (comment). i am not sure this is still needed or wanted. |
i decided to add the HDR/EDR support to the old cocoa-cb/libmpv/opengl backend after all (see PR #14017). reasons are:
|
this is an alternative to #8404
some of the color spaces are probably useless (for now) and can be removed. this should be discussed probably.
there are a lot of color spaces that expect component values below 0.0 and above 1.0. those are currently useless because we only do ranges from 0.0 to 1.0. they are still defined in the enum and need to be removed (same for useless comments):
https://developer.apple.com/documentation/coregraphics/cgcolorspace/3191859-extendedlineardisplayp3
https://developer.apple.com/documentation/coregraphics/cgcolorspace/1644735-extendedsrgb
https://developer.apple.com/documentation/coregraphics/cgcolorspace/1690961-extendedlinearsrgb
https://developer.apple.com/documentation/coregraphics/cgcolorspace/3191861-itur_2020_hlg
https://developer.apple.com/documentation/coregraphics/cgcolorspace/3191862-itur_2020_pq_eotf
https://developer.apple.com/documentation/coregraphics/cgcolorspace/3191860-extendedlinearitur_2020
https://developer.apple.com/documentation/coregraphics/cgcolorspace/3684560-extendeddisplayp3
https://developer.apple.com/documentation/coregraphics/cgcolorspace/3684561-extendeditur_2020
following things are set as default and they most likely change nothing without the color space setting. though if they do, we need to move those to the updateICCProfile call and only conditionally activate it: