mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Problem with opening sdr files in hdr display

Open HenDGS opened this issue 8 months ago • 4 comments

mpv Information

mpv v0.40.0-116-g817372ac9 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
 built on May 18 2025 00:05:55
libplacebo version: v7.351.0 (v7.349.0-79-g3188549-dirty)
FFmpeg version: N-119590-g95c43c6d0
FFmpeg library versions:
   libavcodec      62.3.101
   libavdevice     62.0.100
   libavfilter     11.0.100
   libavformat     62.0.102
   libavutil       60.2.100
   libswresample   6.0.100
   libswscale      9.0.100

Other Information

- Windows version: 24H2
- GPU model, driver and version: RTX 4090, driver 576.40
- Source of mpv: shinchiro build
- Latest known working version: Idk
- Issue started after the following happened: A long time after using mpv without updating

Reproduction Steps

  • Open an sdr file with hdr on

Expected Behavior

Opening an sdr file should not open mpv with hdr and play the sdr file inside an hdr container. I used to use this command "d3d11-output-csp=srgb" to open my files my files with working sdr (as suggested by https://github.com/mpv-player/mpv/issues/8936), but its not working anymore after updating.

I also tried the command "target-trc=srgb" (https://github.com/mpv-player/mpv/issues/14648), but it makes the image a lot darker.

Actual Behavior

Mpv should open in sdr format.

Log File

mpv.log

Sample Files

MPV side by side with VLC, using "d3d11-output-csp=srgb"

Image

MPV side by side with VLC, using "target-trc=srgb" Image

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.

HenDGS avatar May 19 '25 05:05 HenDGS

[ 0.000][v][cplayer] Setting option 'target-colorspace-hint' = 'auto' (flags = 4)

Disable it.

hooke007 avatar May 19 '25 08:05 hooke007

Opening an sdr file should not open mpv with hdr and play the sdr file inside an hdr container.

It should. If your are sending HDR signal to the display, SDR video needs to be passed as HDR too. If not done by mpv, it will be done by compositor. You can adjust --target-peak for optimal SDR viewing to your liking.

If you want to play SDR on SDR, disable HDR in Windows settings.

kasper93 avatar May 19 '25 12:05 kasper93

I've noticed this recently and did some testing on it. Here's what the SDR video looks like on mpv's version of git-master:

mpv --vo=gpu-next(SDR display mode) mpv --vo=gpu-next --target-colorspace-hint=no(HDR display mode) mpv --vo=gpu-next --target-colorspace-hint=no --target-peak=203(HDR display mode) mpc-be(HDR display mode)
2025-05-19 161000 2025-05-19 161023 2025-05-19 161057 2025-05-19 161324

Here are the statistics from the OSD:

mpv --vo=gpu-next(SDR display mode) mpv --vo=gpu-next --target-colorspace-hint=no(HDR display mode) mpv --vo=gpu-next --target-colorspace-hint=no --target-peak=203(HDR display mode)
2025-05-19 161138 2025-05-19 161210 2025-05-19 161232

This is the log file: target-colorspace-hint=no.log target-colorspace-hint=no, target-peak=203.log

It can be confirmed that this was introduced by pr https://github.com/mpv-player/mpv/pull/15279

@kasper93 The real issue here is that the peak brightness information of the display should not be applied for SDR content under --target-colorspace-hint=no, as this is not reliable in HDR display mode, the fact that it screwed up.

When we display SDR as SDR (--target-colorspace-hint=no), we should use the uniform --target-peak default (203) to provide a good display, which is exactly what other players are doing, e.g. vlc, mpc-hc, mpc-be etc. You can see a comparison photo of the mpc-be I provided.

My initial version was using only target peak, but it turns out it is also returned for SDR displays. Like I have one with 270 nits.

I can understand that this is a reasonable need, but if the user's SDR display does have a peak brightness higher than 203 they can set the parameters of the --target-peak option themselves, the player shouldn't have to make the decision for the user, perhaps by providing an attribute for the user to see the actual peak brightness of their display.

In any case the existing practice results in incorrect SDR display under --target-colorspace-hint=no (which is the mpv default) and it should be fixed.

Edit: Here are additional comparison tests

mpv --vo=gpu-next --target-colorspace-hint=auto(HDR display mode) mpv --vo=gpu-next --gpu-api=vulkan --target-colorspace-hint=no(HDR display mode)
2025-05-19 193758 2025-05-19 193840
mpv --vo=gpu-next --target-colorspace-hint=auto(HDR display mode) mpv --vo=gpu-next --gpu-api=vulkan --target-colorspace-hint=no(HDR display mode)
2025-05-19 193805 2025-05-19 193851

We can see that the SDR content is oversaturated with color under --target-colorspace-hint=auto, which is as expected.

The reason why the SDR content looks normal under --gpu-api=vulkan is because the monitor's peak brightness information is not correctly obtained under vulkan, which also seems to be a bug.

This is the log file for --no-config --vo=gpu-next --gpu-api=vulkan --target-colorspace-hint=no: gpu-api=vulkan, target-colorspace-hint=no.log

dyphire avatar May 19 '25 13:05 dyphire

Thanks guys! Using target-colorspace-hint=no + target-peak=203 fixed the issue.

HenDGS avatar May 19 '25 17:05 HenDGS

Should work better now out of the box, will output PQ in HDR mode and not use reported peak in SDR mode. Let me know if there are more issues.

kasper93 avatar Jul 05 '25 21:07 kasper93