mpv-player / mpv

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

d3d11-output-csp should be set according to the content, not the desktop #8936

Open mnisius opened 3 years ago

mnisius commented 3 years ago

Important Information

Provide following Information:

Reproduction steps

Activate HDR Mode in Windows 10 play a SDR movie.

Expected behavior

mpv switches to d3d11-output-csp=srgb I can control the brightness of the video with this windows slider grafik

Actual behavior

mpv plays the sdr video with d3d11-output-csp=pq Now windows thinks it's a hdr movie and I can't control the brightness with the hdr/sdr brightness balance slider and I can't control the brightness of the video with this windows slider

VLC, MPC and every other player I tried seem the work this way. At least the respect the hdr/sdr brightness balance slider. I would be nice if mpv does this as well. I would also be happy for any workaround, because I don't want to change my config each time a play a different movie.

jeeb commented 3 years ago

Yes, it was mostly implemented like it was previously due to the context not having access to the input color space stuff - only the output screen data. I've covered how this could be done in the first PR for the Linux DRM HDR support since it wasn't doing it exactly nicely (but had some OK ideas), and it's on my to-do list to implement this in the VO d3d11 output context.

Doofussy2 commented 3 years ago

All we need is to be able to set the csp at runtime, then we can apply an auto-profile. Having sRGB as the default, but applying pq for bt.2020 media.

mnisius commented 3 years ago

@Doofussy2 I was bored so I wrote this powershell script as a workaround.

$colour_primaries = mediainfo --inform="Video;%colour_primaries%" $args[0]
if($colour_primaries -eq "BT.709") {
   mpv --d3d11-output-csp=srgb --quiet $args[0]
}else {
   mpv --d3d11-output-csp=pq --quiet $args[0]
}
exit

After I wrote it I noticed that you cannot drag and drop files on powershell scripts like on a cmd file. (Why? Windows why?) However you can compile it to an exe with PS2EXE -> https://github.com/MScholtes/PS2EXE and then drag and drop works.

The script needs mpv and mediainfo cli in your PATH Variable. https://mediaarea.net/en/MediaInfo/Download/Windows

Doofussy2 commented 3 years ago

@mnisius I haven't tried this, but you'd need to cover all of the other sdr primaries, too.

https://mpv.io/manual/master/#options-target-prim

jeeb commented 3 years ago

@Doofussy2 well that's part of it all. Also I have a hunch now that there's option cache there already, that the value is already dynamic but it's just not re-applied outside of creating the swap chain. And for making the auto value dynamic (set swap chain color space differently by default for SDR/HDR content) you need to be able to set the value during run time.

Doofussy2 commented 3 years ago

@Doofussy2 well that's part of it all. Also I have a hunch now that there's option cache there already, that the value is already dynamic but it's just not re-applied outside of creating the swap chain. And for making the auto value dynamic (set swap chain color space differently by default for SDR/HDR content) you need to be able to set the value during run time.

That would be great, if it was automatically applied. Is this next on your 'to do' list?

Andy2244 commented 2 years ago

@mnisius Thanks for the script idea, i also could not get SDR content too look nice in HDR/PQ mode (always too dark, washed out), so also needed to switch the --d3d11-output-csp to srgb.

Here is my script with dolby vision support:

# need to remove escaped chars from ps terminal
$filepath = (Get-Item -Path $args[0]).FullName
if ($filepath -eq $null) {
    $filepath = $args[0]
}
$colour_primaries = MediaInfo.exe --inform="Video;%colour_primaries%" "$filepath"
$hdr_format = MediaInfo.exe --inform="Video;%HDR_Format%" "$filepath"
if ($colour_primaries -eq "BT.2020" -Or $hdr_format -eq "Dolby Vision") {
   mpv.exe --profile=HDR --fs --quiet "$filepath" | Out-Null
} else {
   mpv.exe --profile=SDR --fs --quiet "$filepath" | Out-Null
}
# we pipe so kodi can use the compiled script exe as player + playtime detection, so process need stay open

exit

My config/profiles look like this:

vo = gpu-next
hwdec = auto
gamut-mapping-mode = clip
blend-subtitles = no

[HDR]
profile-desc=HDR stuff
profile-cond=p["video-params/primaries"] == "bt.2020"
d3d11-output-csp = pq
target-trc = pq
target-prim = bt.2020
hdr-compute-peak = auto
target-peak = auto
gamma = 4

[SDR]
d3d11-output-csp = srgb
icc-profile-auto
icc-3dlut-size=128x128x128
icc-force-contrast = no
gamma = 3
Hrxn commented 2 years ago

That's a good solution actually..

Andy2244 commented 2 years ago

Updated the powershell script, which i also compiled via win-ps2exe now, so paths also work outside of ps with "open with" and kodi external playerfactory.xml . I also use | Out-Null now so the process stays open while playing, so kodi and other players can use this to detect playtime and set the watched status correctly.