mpv-player / mpv

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

Frame Drops and stuttering with 4K HDR #13946

Closed Vamp898 closed 6 months ago

Vamp898 commented 6 months ago

Important Information

Provide following Information:

Reproduction steps

Playing an FullHD, 4K and 4K HDR File, the 4K HDR file has a lot of frame drops.

According to nvtop, the GPU is around 79% with 51% DEC, so there should be enough headroom to not cause stuttering

It is a bit improved with gpu-next, but not by a lot. Its better, but barely.

Using --profile=fast, the framedrops and so the stuttering is gone

Expected behavior

No Frame Drops until the GPU is at 100%

Actual behavior

Frame Drops

Log file

mpv title_t00.mkv (+) Video --vid=1 (hevc 3840x2160 59.940fps) (+) Audio --aid=1 --alang=jpn (*) 'Stereo' (pcm_s16le 2ch 48000Hz) Using hardware decoding (vaapi). AO: [pipewire] 48000Hz stereo 2ch s16 VO: [gpu-next] 3840x2160 vaapi[p010] AV: 00:00:06 / 01:12:16 (0%) A-V: 0.000 Dropped: 155

Full Logfile: https://ignaz.org/nextcloud/index.php/s/SxzNLE998Sad7LE

truexfan81 commented 6 months ago

from reading the linked log file i have a theory, would you mind providing the output of lspci -nnk | grep -i vga -A3 thanks

Vamp898 commented 6 months ago

@truexfan81 Thanks for the fast reply, sure, nothing easier than that

07:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638] (rev c8) Subsystem: ASUSTeK Computer Inc. Device [1043:8809] Kernel driver in use: amdgpu Kernel modules: amdgpu

truexfan81 commented 6 months ago

well so much for my theory, thanks for that info, what are you using to monitor the gpu usage? i'd like to see if i can get the same results with my 5700XT

decided to edit instead of making the thread longer with another reply, i was not able to reproduce, was only able to get the gpu load up to 18-25% i do have some judder but no dropped frames, looks like most of the time my gpu was running at 61MHz only occasionally clocking up to 800 or so which may explain the judder.

Vamp898 commented 6 months ago

@truexfan81 nvtop (CLI tool). I also tried KDEs System Monitor, but this one, due to how KWin and Plasma is implemented, takes up a lot of GPU Cycles on its own. So its not reliable.

From what i've tested, most reliable results came from nvtop in the good old CLI. This one also shows how much of the GPU is used for decoding and how much is used for actual calculations and so on.

CounterPillow commented 6 months ago

On an iGPU system, your single biggest bottleneck will be memory bandwidth. Instead of hitting high-throughput dedicated GDDR, your GPU is accessing relatively pedestrian at-most 2-channel DDR4 that is shared with the CPU. I heavily doubt that whatever statistics amdgpu exports for nvtop to consume will accurately reflect this bottleneck in whatever percentage of core busy it presents to the user.

Znote commented 6 months ago

I have the same problem/issue as OP. (Edit: Except that mine stutters even when its not fullscreen). Ryzen 9 5900HX, iGPU. Running Ubuntu 24.04

------------ 
OS: Ubuntu Noble Numbat (development branch) x86_64 
Host: MINIPC PN52 
Kernel: 6.8.0-22-generic 
Uptime: 11 hours, 59 mins 
Packages: 2078 (dpkg), 15 (snap) 
Shell: bash 5.2.21 
Resolution: 3840x2160 
DE: GNOME 46.0 
WM: Mutter 
WM Theme: Nordic-v40 
Theme: Yaru-red-dark [GTK2/3] 
Icons: Yaru-red [GTK2/3] 
Terminal: gnome-terminal 
CPU: AMD Ryzen 9 5900HX with Radeon Graphics (16) @ 4.680GHz 
GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series 
Memory: 8365MiB / 31487MiB 

It shouldn't be a hardware performance issue, and it works on other players: VLC: washed screen, doesnt seem to support HDR MPV: Looks good, subs are awesome, but has stuttering and flickering. Default Ubuntu Video player (gnome video player?): Looks good, no stuttering or frame losses, but shitty subtitle support.

CounterPillow commented 6 months ago

Use mpv --show-profile=fast to see what options it applies, then use those not relevant to HDR.

Vamp898 commented 6 months ago

Just tried and played around a bit and i can use all options except the HDR related ones.

So i can use the high-quality profile without issues, 60% GPU usage, runs perfectly fluent. As soon i enable any of the HDR options, even when using the fast profile(+HDR),, i get the frame drops and the stuttering. I can also confirm, that i do not have this issue with other Video Players like VLC.

So High-Quality (without HDR): no issues Fast (with HDR): Stuttering

Another thing i noticed (using the default profile): With vo=gpu, i have a much higher GPU load (98-100%), but only half the frame drops. With vo=gpu-next, the frame drops increase (from 200 to 400 in 10 seconds), but the GPU load goes below 70%.

Using the following profile [hdr] scale=bilinear dscale=bilinear dither=no correct-downscaling=no linear-downscaling=no sigmoid-upscaling=no allow-delayed-peak-detect=yes

With vo=gpu, i end up with 55 dropped frames in 10 seconds (85% GPU Load) with vo=gpu-next i end up with 194 dropped frames in 10 seconds (60% GPU Load)

imho this really doesn't look like an hardware related issue to me. The frame-drops should not increase by the factor of 4 while the GPU load is decreased by 25%. I assume something else is borked here.

But mpv is generally causing higher GPU Load on my System, no matter what i do. Example: Simple 30fps, FullHD YouTube Video

VLC: 2~4% GPU Load mpv (fast): 9% GPU Load mpv (default): 39% GPU Load mpv (high-quality): 48% GPU Load

So maybe something is going wrong in general on my system? Is it KWin? But i used GNOME before Plasma 6 and don't remember mpv causing less GPU Load there.

llyyr commented 6 months ago

iGPUs aren't strong enough to tonemap 4k HDR in most cases, they're bottlenecked by bandwidth due to needing to share system memory.

I don't really understand what you're trying to achieve, but I'd not trust the reported "gpu load" because of the memory bottleneck.

Vamp898 commented 6 months ago

I got the tip to check my BIOS Settings and disable the Setting called "Host Translation Cache" --> Doing so the stuttering is gone.

I can use the default profile without any frame drops and i can use the high quailty setting with an very small amount of frame drops (still 30 drops in 10 seconds but nowhere close to the 200 above).

So i can now, without issues, use the following profiles to watch 4K HDR content on my 4K Screen fast fast+hdr default

And on my WQHD Screen i can even use high-quality without issues now.

Apparently this setting is used to prevent performance penalties but doing a quick Google Search, i do not seem to be the first where disabling it, improves performance.

@Znote Maybe its worth checking out if your BIOS have this feature and, while you're at it, check your UMA Buffer Size. Mine was already set to 2GB but some BIOS have an GAMING Optimized Mode for UMA Buffer size which increases it to 4GB. Maybe that helps too, not sure though. At least for me, that closes this issue.

But that being said, after doing some screenshots (after changing the JPEG Quality to 100%), there is barely any difference. fast and high-quality can look different, but in a lot of cases are identical, even in terms of HDR. You have to go to 200% and know exactly where to look.

So even if it doesn't work for you and/or your BIOS doesn't have this setting, just set the profile to fast and be happy. As long you use vo=gpu-next, the HDR looks amazing.

This is my current config

vo=gpu-next hwdec=auto profile=fast screenshot-jpeg-quality=100 [fasthdr] scale=bilinear dscale=bilinear dither=no correct-downscaling=no linear-downscaling=no sigmoid-upscaling=no allow-delayed-peak-detect=yes hdr-compute-peak=yes [hdr] hdr-compute-peak=yes hdr-peak-percentile=99.995 hdr-contrast-recovery=0.30

I made entries for the context menu so i can choose them depending on the type of video i'm watching, that way its easy to use imho (fast is the default profile as you see in the above profile to save energy/keep the fan quite when watching YT Videos and stuff like that)

image

osumoclement commented 3 months ago

What worked for me is the setting flag --framedrop=no

skjnldsv commented 1 month ago

--profile=fast --hwdec=auto-safe was the trick for me. The --framedrop only creates audio/video sync issues