mpv-player / mpv

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

hwdec=yes creates artifacts in some hdr youtube videos #14193

Closed marat569 closed 1 month ago

marat569 commented 1 month ago

mpv Information

mpv build -- mpv-x86_64-20240519-git-875378f.7z
yt-dlp -- 2024.04.09
ffmpeg-x86_64-git-3f691c0c6.7z

Other Information

Reproduction Steps

Enable HDR mode + Nvidia GPU, and run mpv with these commands

This WILL produce artifacts: mpv --no-config --vo=gpu-next --target-colorspace-hint=yes --target-trc=pq --hwdec=yes https://youtu.be/yCdT448riDY

This will not produce artifacts: mpv --no-config --vo=gpu-next --target-colorspace-hint=yes --target-trc=pq --hwdec=no https://youtu.be/yCdT448riDY

The only difference between the two commands is hwdec=yes (artifacts) and hwdec=no (no artifacts)

Expected Behavior

No Artifacts -.-

Not all YouTube HDR videos produce artifacts with hwdec=yes -- for example this video works perfectly:

mpv --no-config --vo=gpu-next --target-colorspace-hint=yes --target-trc=pq --hwdec=yes https://youtu.be/njX2bu-_Vw4

Something is going on with how YouTube is compressing videos that make some of them go rip

Actual Behavior

You get artifacts, and they aren't due to a faulty gpu decoder or hardware. It seems to be a software issue on our side.

Window's Media Player plays the file back with no artifacts/issues (download the video with yt-dlp, and played it in Media Player)

I've had multiple friends run the command, and we got the same artifacts, like 1:1 on different gpus. A friend even tried MPC-HC and also got the same artifacts.

A friend all this on a Intel A380 (dedicated GPU) and there where no issues with hwdec=yes.

If the artifacts are the exact same, and Chrome + Windows Media Player is able to play these videos just fine, it has to be a software issue

Log File

output.txt

Sample Files

Go to "9 seconds" in the video, and then press . to go 1 frame forward until the time changes from 9 to 10 seconds; and the artifacts should look something like below:

image

The artifacts are the same regardless of CPU or even the player (MPC-HC produces the same exact artifacts)

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

Etc

As a "bandaid fix" I setup this auto-profile in my mpv.conf for all videos that get piped in from youtube:

#Profile for videos streamed via youtube [SDR and HDR] -- add stuff specific to them 
[youtube]
profile-cond=path:find('youtu%.?be')
hwdec=no #hwdec yes causes weird artifacts in some yt videos, so we'll toggle it off

Problem is when you pipe in something like a high bitrate av1 8k video, even my 14900k has a hard time with that with just cpu decoding :c

audaki commented 1 month ago

Can confirm, the exact same artifacts at the exact same spots in the exact same frame on a different PC. (but also an RTX 4090). Only with hwdec=yes, other params don’t change a thing.

Andarwinux commented 1 month ago

Can confirm that all internal hwaccel hwdec have this problem (hwdec=dxva2|d3d11va|d3d12va|nvdec), but decoder wrapper hwdec is fine (hwdec=cuda|vd=vp9_cuvid)

kasper93 commented 1 month ago

Likely duplicate of #13533 Likely fixed by https://patchwork.ffmpeg.org/project/ffmpeg/patch/CZHCF9QL07FJ.3VOACXA14QCVF@yukari.in/ (if it ever get merged)

marat569 commented 1 month ago

Likely duplicate of #13533 Likely fixed by https://patchwork.ffmpeg.org/project/ffmpeg/patch/CZHCF9QL07FJ.3VOACXA14QCVF@yukari.in/ (if it ever get merged)

interesting, I had a feeling this would end up another "this is ffmpeg's fault" -- hopefully they merge the pull request; maybe there's a way to reach out to the ffmpeg bois?

So what do you suggest is a good bandaid fix for now? setting hwdec=cuda for my youtube auto profile

Or setting the ffmpeg setting mentioned in the other github issue -- and if that's better how would I go about editing an ffmpeg setting; never messed with it before? And would it be possible to have that setting changed only for yt videos -- like be part of my autoprofile

Workaround for ffmpeg setting segmentation_update_map to 1 with segmentation_enabled == 0

thank you!

llyyr commented 1 month ago

interesting, I had a feeling this would end up another "this is ffmpeg's fault" -- hopefully they merge the pull request; maybe there's a way to reach out to the ffmpeg bois?

@philipl said he'll merge the patch next week, in the meantime you can build mpv yourself with that commit included in ffmpeg

marat569 commented 1 month ago

interesting, I had a feeling this would end up another "this is ffmpeg's fault" -- hopefully they merge the pull request; maybe there's a way to reach out to the ffmpeg bois?

@philipl said he'll merge the patch next week, in the meantime you can build mpv yourself with that commit included in ffmpeg

Awesome! I dont have any IDEs setup on my current windows install, so this can wait until next week <3

Out of curiosity: If the issue stems from ffmpeg, how come players like MPC-HC and VLC exhibit the same exact issue?

Or is the issue not ffmpeg's "fault" -- but ffmpeg is just responsible for the fix?

Andarwinux commented 1 month ago

Awesome! I dont have any IDEs setup on my current windows install, so this can wait until next week <3

You don't need install VS, just use WSL2 to build your own mpv in half an hour.

Out of curiosity: If the issue stems from ffmpeg, how come players like MPC-HC and VLC exhibit the same exact issue?

The bug is caused by ffvp9, so any player using ffmpeg's internal hwaccel will have the same bug, but hwdec=cuda is fine because cuvid uses its own decoder implementation.

marat569 commented 1 month ago

Awesome! I dont have any IDEs setup on my current windows install, so this can wait until next week <3

You don't need install VS, just use WSL2 to build your own mpv in half an hour.

Out of curiosity: If the issue stems from ffmpeg, how come players like MPC-HC and VLC exhibit the same exact issue?

The bug is caused by ffvp9, so any player using ffmpeg's internal hwaccel will have the same bug, but hwdec=cuda is fine because cuvid uses its own decoder implementation.

Thanks for the info

also sadly hwdec=cuda doesnt actually use my entire gpu

I tested it vs. an av1 high bitrate video; and it still pegged my 14900k and dropped a ton of frames -- while hwdec=yes played it back just fine

so I'll just wait for the mpv update; my little auto-profile for yt videos with hwdec=cuda will work just fine for now

Andarwinux commented 1 month ago

so I'll just wait for the mpv update; my little auto-profile for yt videos with hwdec=cuda will work just fine for now

If you need, you can try my personal build with vp9 patch.

marat569 commented 1 month ago

so I'll just wait for the mpv update; my little auto-profile for yt videos with hwdec=cuda will work just fine for now

If you need, you can try my personal build with vp9 patch.

Thank you so much <3

philipl commented 1 month ago

ffmpeg patch has been merged as https://github.com/FFmpeg/FFmpeg/commit/2b11a8b95b4ff27624330bd417da63b5c7c9367e

marat569 commented 1 month ago

Thanks a lot guys <3

Just for clarification, for the issue to be resolved; do I just need a new ffmpeg.exe or also a new mpv.exe?

I'm using Andarwinux's build right now that he posted a bit earlier.

What I'm asking is when I run updater.bat, what needs to get updated mpv.exe or just ffmpeg.exe (whenever the releases are made)

llyyr commented 1 month ago

ffmpeg

marat569 commented 1 month ago

I assume shinichiro's next nightly will have the updated ffmpeg?

llyyr commented 1 month ago

yeah it should

marat569 commented 1 month ago

It does! Thanks everybody!

I'll stop replying to the issue and stop flooding your inboxs