mpv icon indicating copy to clipboard operation
mpv copied to clipboard

HDR brightness incorrect at mac built-in screen

Open waiwaib opened this issue 1 year ago • 4 comments

mpv Information

mpv 0.38.0 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.349.0
FFmpeg version: 7.0.2
FFmpeg library versions:
   libavutil       59.8.100
   libavcodec      61.3.100
   libavformat     61.1.100
   libswscale      8.1.100
   libavfilter     10.1.100
   libswresample   5.1.100

Other Information

- macOS version: 14.4.1
- Source of mpv: homebrew
- Introduced in version: NA

Reproduction Steps

  1. A Macbook with XDR(1600 nit) (eg: Macbook Air M2 build-in )

  2. brew install mpv

mpv --no-config --hwdec=hevc-videotoolbox --vo=gpu-next --target-colorspace-hint=yes example_p5.ts now can see the mpv shows about 60%-70% peak-white: shot_mpv

  1. below is the full brightness case with infuse play:

infuse

Expected Behavior

mpv play the Dolby p5 file with peak-white

Actual Behavior

mpv shows about 60%-70% peak-white

Log File

output.txt

Sample Files

https://www.dropbox.com/scl/fi/1c0acxv19qwcey6xqx1k4/sample_p5.ts?rlkey=ix530a9ngum1x0rjxe7fpzuq0&st=uosf8bgm&dl=0

I carefully read all instruction and confirm that I did the following:

  • [X] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [X] I provided all required information including system and mpv version.
  • [X] I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • [X] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [X] I attached the full, untruncated log file.
  • [X] I attached the backtrace in the case of a crash.

waiwaib avatar Sep 03 '24 06:09 waiwaib

i am not quite sure why you expect this, though you might need to play with target-peak and hdr-compute-peak options. the latter is most likely activated in your case and PQ(Y) max is calculated as ~645cd/m^2 in that case. so you won't get 1600nits output.

Screenshot 2024-10-13 at 15 17 44

Akemi avatar Oct 13 '24 13:10 Akemi

i am not quite sure why you expect this, though you might need to play with target-peak and hdr-compute-peak options. the latter is most likely activated in your case and PQ(Y) max is calculated as ~645cd/m^2 in that case. so you won't get 1600nits output.

Screenshot 2024-10-13 at 15 17 44

I found that in many cases, even though mpv has implemented the edrmetadata setting according to Apple's documentation, the maximum brightness is still incorrect. so I want to know the root cause and expect to get the correct brightness. so, as you said, I can understand that mpv&libplacebo don't know the mastering display's peak white in nits, if I know the buildin screen is XDR(1600nit), I need to set the target-peak=1600&hdr-compute-peak=yes to let the mpv/libplacebo knows PQ(Y) max should be calculated as 1600cd/m^2 in that case. I will try your suggestion, thanks. byw, can you kindly tell me how to display the playing debug info~ I think that will help me a lot!

waiwaib avatar Oct 13 '24 13:10 waiwaib

just to make things clear. the maximum PX(Y) is the max brightness of the video, not the display. mpv knows the peak brightness of the display if the colour profile set has the appropriate fields set. though the standard macOS profiles might not have that field set. in that case target-peak needs to be set to the appropriate value.

hdr-compute-peak calculates the peak and average brightness per frame. from the docs

Compute the HDR peak and frame average brightness per-frame instead of relying on tagged metadata.

so since the calculated values is ~645cd/m^2 (and ~70% of max, at least that how understand the number in the screenshot), it's expected that peak brightness in your case is 70% of you display's 1600nits.

though i could be completely wrong too. i didn't look into all the HDR stuff myself and still try to find the appropriate settings myself.

you can show the stats with i or shift+i (toggle), see also https://github.com/mpv-player/mpv/blob/master/DOCS/man/stats.rst

Akemi avatar Oct 13 '24 14:10 Akemi

just to make things clear. the maximum PX(Y) is the max brightness of the video, not the display. mpv knows the peak brightness of the display if the colour profile set has the appropriate fields set. though the standard macOS profiles might not have that field set. in that case target-peak needs to be set to the appropriate value.

hdr-compute-peak calculates the peak and average brightness per frame. from the docs

Compute the HDR peak and frame average brightness per-frame instead of relying on tagged metadata.

so since the calculated values is ~645cd/m^2 (and ~70% of max, at least that how understand the number in the screenshot), it's expected that peak brightness in your case is 70% of you display's 1600nits.

though i could be completely wrong too. i didn't look into all the HDR stuff myself and still try to find the appropriate settings myself.

you can show the stats with i or shift+i (toggle), see also https://github.com/mpv-player/mpv/blob/master/DOCS/man/stats.rst

Got it. I will try to find the appropriate settings for my Mac. appreciate your help.

waiwaib avatar Oct 13 '24 15:10 waiwaib

Iirc, with target-colorspace-hint, mpv sets target-peak to Mastering Display Luminance (MDL) by default. In most cases it's either 1000 nits or 4000 nits, which can be too low or too high depending on your display. Thus we need to tinker target-peak and hdr-compute-peak. However, how target-peak behaves in HDR is not clearly documented. The manual is mainly about emulating HDR in SDR mode.

I wonder if it should be set to something that's related to user's display based on ICC file or EDID, or if tone-mapping should be handled by other things instead of mpv.

Robot-DaneelOlivaw avatar Oct 28 '24 05:10 Robot-DaneelOlivaw

However, how target-peak behaves in HDR is not clearly documented. The manual is mainly about emulating HDR in SDR mode.

HDR and SDR is only a name, it is all about setting luminance level of your display device and sending signal that fits nicely in its capabilities. Set target-peak to the peak of your display. Set target-trc and target-prim if you want or not.

I wonder if it should be set to something that's related to user's display based on ICC file or EDID

icc-use-luma will use ICC luminance measured value as target-peak. Currently there is no code to read EDID in mpv.

Note that ICC profile won't work well if HDR metadata is sent to the display directly. Because depending on the hardware processing or switching of the modes, you need to have ICC profile measured at given mode of the display. But if you set display in "HDR mode" and measure that, you can use this feature. It is always bit tricky, because there are multiple moving pieces here, so not really easy to handle this all automatically.

if tone-mapping should be handled by other things instead of mpv.

mpv tone-mapping will be higher-quality than anything else in pipeline after mpv. You might send higher luminance signal to your display, but it will likely apply basic tone-mapping or clip the values. Depends on the implemented method.

Hope that clears things, let me know if you have any questions.

kasper93 avatar Oct 28 '24 06:10 kasper93

HDR and SDR is only a name, it is all about setting luminance level of your display device and sending signal that fits nicely in its capabilities. Set target-peak to the peak of your display. Set target-trc and target-prim if you want or not.

Thanks for replying. I just switched from SDR to HDR and kept the impression that mpv used BT.2390 by default. So I kinda expected the brightness to "soft clip" at target-peak and got confused. But it turns out that libplacebo uses spline now, it does look a bit different from BT.2390. And yeah target-peak should still be set to display peak brightness.

Robot-DaneelOlivaw avatar Oct 30 '24 17:10 Robot-DaneelOlivaw

going to close this issue, since everything has been answered so far. if anything else arrises feel free to open a new one or a discussion.

Akemi avatar Oct 30 '24 18:10 Akemi