mpv icon indicating copy to clipboard operation
mpv copied to clipboard

hwdec=yes creates artifacts in some hdr youtube videos

Open marat569 opened this issue 1 year ago • 8 comments

mpv Information

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

Other Information

  • Windows version: w11 23h2
  • RTX 4090

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:

  • [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.

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

marat569 avatar May 21 '24 01:05 marat569

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.

audaki avatar May 21 '24 08:05 audaki

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)

Andarwinux avatar May 21 '24 14:05 Andarwinux

Likely duplicate of #13533 Likely fixed by https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/ (if it ever get merged)

kasper93 avatar May 21 '24 15:05 kasper93

Likely duplicate of #13533 Likely fixed by https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/ (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!

marat569 avatar May 22 '24 00:05 marat569

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

llyyr avatar May 22 '24 05:05 llyyr

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?

marat569 avatar May 22 '24 05:05 marat569

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.

Andarwinux avatar May 22 '24 06:05 Andarwinux

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

marat569 avatar May 22 '24 07:05 marat569

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.

Andarwinux avatar May 24 '24 14:05 Andarwinux

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

marat569 avatar May 25 '24 00:05 marat569

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

philipl avatar May 27 '24 15:05 philipl

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)

marat569 avatar May 27 '24 21:05 marat569

ffmpeg

llyyr avatar May 28 '24 02:05 llyyr

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

marat569 avatar May 28 '24 02:05 marat569

yeah it should

llyyr avatar May 28 '24 02:05 llyyr

It does! Thanks everybody!

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

marat569 avatar May 28 '24 02:05 marat569