mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.1k stars 2.88k forks source link

target-peak does not work with videos streamed via mpv youtube.com/videoblabla (or any streaming site) #13609

Closed marat569 closed 7 months ago

marat569 commented 7 months ago

MPV Version: mpv-x86_64-20240225-git-74b4c3c

Windows 11 23h2 [Version 10.0.22631.3155]

Nvidia GPU

Update: Andarwinux discovered that if a video's max_luminance is less than or equal to your target-peak, MPV will not engage in tonemapping.

The issue there is a lot of videos might set max_luminance to 1000, but output a 10,000 nit image. A good example is this one: mpv https://youtu.be/BditFs3VR9c Even though it has a max_luminance of 1000 in the hdr metadata, the video outputs a 10,000 nit image.

In my opinion we need a way to force mpv to tonemap to our desired target peak regardless of what the hdr metadata says.

While it may be accurate on blurays, youtube video metadata is a meme.


so the issue is simple, if you run mpv https://youtu.be/72_rYwzLhjk for example with vo=gpu-next and target-colorspace-hint=yes -- target-peak will NOT activate; and the video will not get tonemapped; the raw untonemapped video will be presented

I tried streaming different sites via mpv website.com/video and anything that gets streamed into mpv does not get target peak applied

I made a little custom if profile in my conf for youtube videos to try and force target-peak, and even a hotkey that forces it -- nothing

if you set target-colorspace-hint=no -- it will tonemap; but the video wont be in HDR; you'll get a SDR image

I tried a wide range of settings, and this is what I've came to

Sorry if the issue does not have every single requested detail, if you want any more info feel free to ask -- I'll reply asap with any additional info -- please don't just instantly close the issue :sadge:

Thank you!

marat569 commented 7 months ago

mpv.conf.zip

Here is the conf I run as a daily driver. I tried blank confs, confs with just vo=gpu-next, etc -- didn't work sadly

Traneptora commented 7 months ago

Can you post a log file?

marat569 commented 7 months ago

Can you post a log file?

output.txt

Here you go! I watched the video in the original post for a few seconds

quietvoid commented 7 months ago

the raw untonemapped video will be presented

What does that mean? Is your display simply not switching to HDR mode? Did you try enabling HDR for it in the Windows settings?

marat569 commented 7 months ago

the raw untonemapped video will be presented

What does that mean? Is your display simply not switching to HDR mode? Did you try enabling HDR for it in the Windows settings?

You can see when tonemapping is happening via shift I to open the OSD, and "2"; you'll see tonemapping XXXX -> YYYY -- this sadly does not happen in videos with mpv youtube.com/blabla

In this image, MPV is tonemapping to 1000 nits, but its not a streamed video; but a local video file; so everything works https://i.imgur.com/DwgJiBc.jpeg

quietvoid commented 7 months ago

I can't reproduce the issue with the youtube video:

mpv --no-config --vo=gpu-next --target-trc=pq --target-colorspace-hint --target-peak=1000 https://youtu.be/72_rYwzLhjk 

The statistics show tonemap XXXX -> 1000 nits.

marat569 commented 7 months ago

I can't reproduce the issue with the youtube video:

mpv --no-config --vo=gpu-next --target-trc=pq --target-colorspace-hint --target-peak=1000 https://youtu.be/72_rYwzLhjk 

The statistics show tonemap XXXX -> 1000 nits.

I just pasted that into my run bar, doesn't for me -- let me try to add a log

I even took a jxr, and the output is 2000 nits+

marat569 commented 7 months ago

I can't reproduce the issue with the youtube video:

mpv --no-config --vo=gpu-next --target-trc=pq --target-colorspace-hint --target-peak=1000 https://youtu.be/72_rYwzLhjk 

The statistics show tonemap XXXX -> 1000 nits.

I ran this, and target-peak is not getting applied. I'm running update.bat constnatly, so my version is new as you can see from the log

mpv --no-config --vo=gpu-next --target-trc=pq --target-colorspace-hint --target-peak=1000 https://youtu.be/72_rYwzLhjk --log-file=output.txt" (just added a log file to your command)

output.txt

Andarwinux commented 7 months ago

This video max_luminance is 1000.000000, so this is the expected behavior. You can try --target-peak=999

marat569 commented 7 months ago

This video max_luminance is 1000.000000, so this is the expected behavior. You can try --target-peak=999

I tried 500 for fun, and yea its tonemapping. Thank you! 999 is also a solid work around.

Can we get a way to force target-peak?

Because a lot of videos on youtube set a max_luminance of 1000; but they still output a 10,000 nit (full hdr10 signal) image -- or in this video's case, up to 3000 nits.

Here is an example of such a video: mpv https://youtu.be/BditFs3VR9c -- even though the peak is set to 1000, the output is 10k nits.

Andarwinux commented 7 months ago

Can we get a way to force target-peak?

hdr-compute-peak=yes But target-peak can't be the same as max_luminance, for example, target-peak can be 999 or 1001 when max_luminance is 1000.

marat569 commented 7 months ago

Can we get a way to force target-peak?

hdr-compute-peak=yes But target-peak can't be the same as max_luminance, for example, target-peak can be 999 or 1001 when max_luminance is 1000.

Trusting max_luminance is a good idea on paper for something like a bluray, because that will usually have it set proper; but as we've seen youtube videos set meme static metadata. 999 isnt really far off from 1000; so its not a big deal.

Also I don't know if I'm using hdr-compute-peak wrong. I tried both yes and no with target-peak 1000; and it doesnt tonemap.

I was asking for a setting for where I can set target-peak=1000 and regardless of what the max_luminance is set to, it will still respect my target-peak and tonemap if the frame has a MaxCLL over 1000 in this case

Andarwinux commented 7 months ago

Also I don't know if I'm using hdr-compute-peak wrong. I tried both yes and no with target-peak 1000; and it doesnt tonemap.

I don't know if this is expected behavior or a bug, but when target-peak same as max_luminance, tone-mapping is always disabled anyway, even if peak detection gets a completely different result than max_luminance. 1001/999 is an ugly hack.

marat569 commented 7 months ago

Also I don't know if I'm using hdr-compute-peak wrong. I tried both yes and no with target-peak 1000; and it doesnt tonemap.

I don't know if this is expected behavior or a bug, but when target-peak same as max_luminance, tone-mapping is always disabled anyway, even if peak detection gets a completely different result than max_luminance. 1001/999 is an ugly hack.

Right, but its something we need, because if you look at this video for example -- https://youtu.be/BditFs3VR9c

max_luminance 1000, but you get fed a juicy 10k nit image

I don't know if youtube is the issue when it comes to shipping bad static metadata or the content creator; but a ugly hack is better than watching full screen clipping

quietvoid commented 7 months ago

This should not be an issue with hdr-compute-peak, you should make sure it does get enabled.

It works for me.

marat569 commented 7 months ago

I tried hdr-compute-peak=no (and yes) again

So in the OSD (shift + i) I can see that the MaxCLL is not being calculated

But with target-peak=1000, I still don't get any tone mapping in youtube videos.

I feel like youtube videos might need a workaround.

I've tried dozens of different videos since starting this issue, and the HDR metadata youtube sends out is "wrong".

kasper93 commented 7 months ago

https://code.videolan.org/videolan/libplacebo/-/merge_requests/653

marat569 commented 7 months ago

https://code.videolan.org/videolan/libplacebo/-/merge_requests/653

Awesome, thank you so much!

marat569 commented 7 months ago

@kasper93

I'm sorry to bother ya'll after you guys fixed the issue, but how long does it take for a mpv update after libplacebo gets approved?

I never worried about MPV versions before since I use the windows downstream release with updater.bat that just grabs new mpv.exe/mpv.conf based on my repo confs (weekly/nightly/etc)

kasper93 commented 7 months ago

If you are using shinchiro's build, next one will have it. zhongfly's build should have it already https://github.com/zhongfly/mpv-winbuild/releases/tag/2024-03-08-414ddbd

marat569 commented 7 months ago

pretty sure I use shinchiro's

thank you!