mpv-player / mpv

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

Incorrect colors when playing H264 with BT.601 color matrix via vo=gpu-next #12446

Open Drommer opened 1 year ago

Drommer commented 1 year ago

Following Information:

The picture is darker than it should be. The problem is confirmed when playing AVC video. This problem does not occur with MPEG2 (DVD).

The source is DVD Video. H264 transcoded from this DVD using x264. Screens: https://imgsli.com/MjA3NzUx Sample: https://www.sendspace.com/file/ec7hr7 MediaInfo: https://pastebin.com/raw/zW9FrVze

gpu-next.log gpu.log

natural-harmonia-gropius commented 1 year ago

Does gamut-mapping-mode=clip fix this?

llyyr commented 1 year ago

Darker relative to what? You need to provide screenshots and samples.

Drommer commented 1 year ago

Does gamut-mapping-mode=clip fix this?

No? it doesn't.

Darker relative to what? You need to provide screenshots and samples.

The source is DVD Video. H264 transcoded from this DVD using x264. Screens: https://imgsli.com/MjA3NzUx Sample: https://www.sendspace.com/file/ec7hr7 MediaInfo: https://pastebin.com/raw/zW9FrVze

haasn commented 1 year ago

Can you post a log with --vo=gpu also?

Drommer commented 1 year ago

gpu-next.log gpu.log

dyphire commented 1 year ago

Does --target-trc=gamma2.2 help this?

Drommer commented 1 year ago

Does --target-trc=gamma2.2 help this?

No

haasn commented 1 year ago

So, I think this is actually a vo_gpu bug. Your video is tagged as having a gamma2.8 transfer, but vo_gpu ignores this and treats it as gamma 2.2 instead.

If you believe this to be a tagging error you can override it using --vf=format:transfer=gamma2.2, or fix the file directly. Though, just from visual inspection, I'm not sure which of the two is supposed to be "correct". The gamma 2.2 version seems a bit blown out.

Drommer commented 1 year ago

I tried playing this video in mpv with vo=dmabuf-wayland, VLC Player, MPC-HC (on Windows). All of them show the same result as vo=gpu and match the original DVD.

I had my doubts that I had done something wrong with the encoding. So I download another DVD and someone else's DVDRip-AVC to compare. In this case I found that vo=gpu-next produced a too dark picture not only in H.264 but also in the original MPEG2. The screenshots are attached.

DVD: https://imgsli.com/MjA3OTY3 AVC: https://imgsli.com/MjA3OTY5

Screenshot from VLC

ValeZAA commented 11 months ago

That video has gamma 2.8 tag. That means the video asks for display of gamma 2.8. VLC is not color managed (outside MacOS and even there you need to set it up) and MPC does not support change of gamma function, you need Madvr+MPC. Please note that BT.601 matrix and limited range are applied correctly. You can override matrix with --vf=format=colormatrix=bt.709 or --vf=format=colormatrix=bt.2020-ncl (and range too with another option).

I would ask you to show mediainfo on original dvd rip.

Also what display do you have? If it is typical 2.2 gamma display with sRGB primaries you need to use --target-trc=gamma2.2 --target-prim=bt.709

If your display is 2.4 gamma --target-trc=gamma2.4 --target-prim=bt.709

Drommer commented 11 months ago

If your display is 2.4 gamma --target-trc=gamma2.4 --target-prim=bt.709

Okay, this seems like a solution. I don't know if this is possible to implement. But it would be nice if this conversion could be done automatically. DVD-MI.txt DVDRip-MI.txt

haasn commented 11 months ago

Okay, this seems like a solution. I don't know if this is possible to implement. But it would be nice if this conversion could be done automatically.

But we already default to gamma2.2, a value typical of desktop monitors.