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

Artifacts in Some YouTube HDR Videos When Trying to Playback Using Hardware Decoding #595

Closed
DedZasshu opened this issue May 19, 2024 · 14 comments

Comments

@DedZasshu
Copy link

DedZasshu commented May 19, 2024

  • LAV Filters 0.79.2
  • GPU: NVIDIA GeForce RTX 3080, drivers 552.44
  • Windows 11 Home 23H2 22631.3593
  • MPC-HC 2.2.1

I've noticed that in some YouTube videos, when trying to watch in HDR, they show blocky artifacts when trying to playback using hardware decoding on MPC-HC (or even MPV's d3d11va). They playback fine if I disable hardware decoding, which would make me assume that it's a hardware bug or something, but somehow YouTube can playback the same videos just fine using hardware decoding without any blocky artifacts.

Here's one example of what's going on:
Gamut Rings_ A better way to measure color 5_19_2024 10_05_43 AM

And here's the mediainfo for that video:
mediainfo.txt

@DedZasshu DedZasshu changed the title Artifacts in Some YouTube Videos When Trying to Watch Using HDR at 4K+ Using Hardware Decoding Artifacts in Some YouTube HDR Videos When Trying to Watch Using Hardware Decoding May 19, 2024
@DedZasshu DedZasshu changed the title Artifacts in Some YouTube HDR Videos When Trying to Watch Using Hardware Decoding Artifacts in Some YouTube HDR Videos When Trying to Playback Using Hardware Decoding May 19, 2024
@clsid2
Copy link
Contributor

clsid2 commented May 19, 2024

Confirm. Blocky artifacts clearly visible. Most obvious segment 00:18 to 00.21 and starting at 01:48

Also happens with DXVA2-cb.

@DedZasshu
Copy link
Author

Confirm. Blocky artifacts clearly visible. Most obvious segment 00:18 to 00.21 and starting at 01:48

Also happens with DXVA2-cb.

Yeah, I also tried using that and D3D11 (Copyback) and still got the same results.

@lvqcl
Copy link

lvqcl commented May 19, 2024

I can see the artifacts when I use nvidia card to decode (d3d11 native or copyback), but not when I use integrated intel 750 (d3d11 copyback).

@DedZasshu
Copy link
Author

DedZasshu commented May 19, 2024

I can see the artifacts when I use nvidia card to decode (d3d11 native or copyback), but not when I use integrated intel 750 (d3d11 copyback).

My A380 can playback without much issues using d3d11 copyback, too. So it probably is some NVIDIA hwdec bug or something. Which, again, makes me wonder how YouTube got it to work properly with NVIDIA hwdec...

@L4cache
Copy link

L4cache commented May 20, 2024

test with ffplay -hwaccel vulkan don't have the artifact
all others either have artifacts or just don't display anything, the no display part is due to ffplay uses vulkan renderer when hwaccel is enabled, and some hwaccel is incompatible with it, I think.
then I use ffmpeg to do hwdec then transcode, every hwaccel that is compatible with my hardware can output image, vulkan decoder is still the only one that have no artifact, others are dxva2, d3d11va, d3d12va and cuda (nvdec I guess), all have artifact.
I also tried the deprecated (iirc) cuvid method, like ffmpeg -c:v vp9_cuvid -i xxx and also found no artifact. lavfilters also have it.

@lvqcl
Copy link

lvqcl commented May 20, 2024

And browsers use Media Foundation interface, not DXVA/D3D11/D3D12.

@DedZasshu
Copy link
Author

And browsers use Media Foundation interface, not DXVA/D3D11/D3D12.

So I'm guessing it's a DirectX/Direct3D related bug?

@clsid2
Copy link
Contributor

clsid2 commented May 21, 2024

Media Foundation uses D3D11/12.

The main difference is the decoder implementation that feeds the hardware decoder. FFmpeg vs MS.

@DedZasshu
Copy link
Author

Media Foundation uses D3D11/12.

The main difference is the decoder implementation that feeds the hardware decoder. FFmpeg vs MS.

Ah, so it's an FFmpeg bug.

Nevcairiel added a commit that referenced this issue May 22, 2024
@Nevcairiel
Copy link
Owner

Please try https://files.1f0.de/lavf/nightly/LAVFilters-0.79.2-2.exe, it seems to work now on my end.

@kasper93
Copy link
Contributor

kasper93 commented May 22, 2024

There is also this patch https://patchwork.ffmpeg.org/project/ffmpeg/patch/CZHCF9QL07FJ.3VOACXA14QCVF@yukari.in/ that possibly fixes more hwdecs than patching in dxva2_vp9.c.

For reference:
mpv-player/mpv#13533
mpv-player/mpv#14193

@DedZasshu
Copy link
Author

DedZasshu commented May 22, 2024

Please try https://files.1f0.de/lavf/nightly/LAVFilters-0.79.2-2.exe, it seems to work now on my end.

Oh wow, it works! Can't wait for it to be integrated into MPC-HC (w/ K-Lite Codec Pack!)

There is also this patch https://patchwork.ffmpeg.org/project/ffmpeg/patch/CZHCF9QL07FJ.3VOACXA14QCVF@yukari.in/ that possibly fixes more hwdecs than patching in dxva2_vp9.c.

For reference: mpv-player/mpv#13533 mpv-player/mpv#14193

That would be great to improve LAV as much as possible.

@DedZasshu
Copy link
Author

DedZasshu commented May 22, 2024

I think this should be good enough to close this issue since it's been noticed and being taken cared of.

Edit: Actually, just going to reopen until the fix is pushed on a stable release.

@DedZasshu DedZasshu reopened this May 25, 2024
@Nevcairiel
Copy link
Owner

Issues are historically closed when fixed, releases happen when they happen.

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

No branches or pull requests

6 participants