Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
6 tasks done
marat569 opened this issue May 21, 2024 · 16 comments
Closed
6 tasks done

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

marat569 opened this issue May 21, 2024 · 16 comments

Comments

@marat569
Copy link

marat569 commented May 21, 2024

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:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • 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.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • 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

@audaki
Copy link

audaki commented May 21, 2024

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
Copy link
Contributor

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
Copy link
Contributor

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

@marat569
Copy link
Author

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
Copy link
Contributor

llyyr commented May 22, 2024

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

marat569 commented May 22, 2024

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Member

philipl commented May 27, 2024

ffmpeg patch has been merged as FFmpeg/FFmpeg@2b11a8b

@philipl philipl closed this as completed May 27, 2024
@marat569
Copy link
Author

marat569 commented May 27, 2024

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
Copy link
Contributor

llyyr commented May 28, 2024

ffmpeg

@marat569
Copy link
Author

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

@llyyr
Copy link
Contributor

llyyr commented May 28, 2024

yeah it should

@marat569
Copy link
Author

It does! Thanks everybody!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants