mpv-player / mpv

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

Solutions to solve video judder #10388

Closed andyzukunft closed 2 weeks ago

andyzukunft commented 2 years ago

Hey everyone,

I have a huge problem with video judder. At least I think it's video judder. It took me quiet some time to name it. I bought a new TV (Samsung QN90A 85") in September 2021 and I have problems with video judder ever since (depending on the movie/series/anime more or less).

Example videos (120 Hz monitor refresh rate, ~24 Hz video, recording with 60 Hz, no special mpv.conf)
https://drive.google.com/drive/folders/1FdRWZKdzFX_cztwKKqjZSbAbSLRkEA2Y?usp=sharing

In my opinion those videos show you nicely what I see on the screen.

Hardware / software setup

Basic mpv.conf

#See MPV documentation: https://mpv.io/manual/master/#video
#See example: https://github.com/ThomasEricB/Mpv.Net-HQ-Config/blob/main/mpv.conf

# Video Hardware
vo=gpu
profile=gpu-hq
hwdec=auto
gpu-api=vulkan
vulkan-swap-mode=mailbox

Working solution (but flawed)
My example video reports a frame rate of 23.809525 fps (which sounds weird). Setting my display to 24 fps does not solve judder (which is logical if the reported frame rate is correct). After days of searching I found the name for my problem (-> judder) and a working solution:
Setting my display to 24 fps and

  1. configuring video-sync=display-resample changes the behaviour, stuttering less often however with a far more annoying frame drop
  2. installing the script autospeed and configuring it with script-opts=autospeed-xrandr=false,autospeed-speed=true,autospeed-display=auto,autospeed-exitmode=auto,autospeed-minspeed=0.9,autospeed-maxspeed=1.1,autospeed-osd=true,autospeed-estfps=false

HOWEVER: it has to be 24 fps. If I set it to 120 fps (multiple of 24) the juddering is still there.

Trying VRR (and failing)
I tried enabling VRR which is nice as changing the refresh rate with autospeed works neatless. However I keep on having judder independently of the set refresh rate (24, 72). The autospeed OSD reports the correct data (e.g. 72 Hz display, 23.x fps video, speedup video to 24 fps). The display refresh rate matches the OSD of my TV (e.g. 60 Hz before video start, 72 after autospeed changed it).

Interpolation doesn't help I have experimented with interpolation with options oversample, triangle and sphinx (of course with video-sync=display-resample) but it doesn't solve my issue.

mpv.conf additions for interpolation

# BUILT-IN MOTION INTERPOLATION
interpolation=yes
tscale=oversample # Enables the 'smoothmotion' for interpolation.
#tscale=triangle

#tscale=sphinx
#tscale-blur=0.6991556596428412

Journey continues? The multimedia PC I am using in the living room is also used for other things, and having it at 24 fps and setting it manually is uncomfortable. Setting autospeed-xrandr=true is switching to 120 Hz (-> doesn't help me).

This leads me to the questions:

haasn commented 2 years ago

What do you mean by "far more annoying framedrop" when using display-resample? That shouldn't be dropping any frames!

andyzukunft commented 2 years ago

Well, beforehand the motion was blurry and perception depended on video panning, now I get hard framedrops and image distortions. Please see my example videos for an added example. Similar result with 120 Hz display refresh rate.

Example videos (recorded with 60 fps camera) https://drive.google.com/drive/folders/1FdRWZKdzFX_cztwKKqjZSbAbSLRkEA2Y?usp=sharing

Active mpv.conf for the video Amdgpu_VideoIssue_1_24hz_videosync_displayresample.mp4:

# Video Hardware
vo=gpu
profile=gpu-hq
hwdec=auto
gpu-api=vulkan
vulkan-swap-mode=mailbox

video-sync=display-resample

I think we may have found a problem with the vulkan video output. If I set my config to

# Video Hardware
vo=gpu
profile=gpu-hq
hwdec=auto

video-sync=display-resample

at 24 Hz the video looks mostly smooth however it has some distortion (but far less often). Maybe this is tearing - which also shouldn't happen with video sync to display? At 120 Hz it looks as my original example video with a lot of judder.

natural-harmonia-gropius commented 2 years ago

That shouldn't be dropping any frames!

It does, when the device can't handle it. The cost of display-resample, dither and osd/sub render more than expected. Are them rendered in scaled resolution?or native resolution? I'm guessing this because only high-resolution video would produce such a result image image image

sample: https://www.youtube.com/watch?v=oYqGt4zrpUE 8k60p AV1

andyzukunft commented 2 years ago

Thats a fair question. The video in question has a 1080p resolution. Sooo a modern AMD iGPU should handle this. Of course I actually checked this.

Benchmark /w Vulkan

# Video Hardware
vo=gpu
profile=gpu-hq
hwdec=auto
gpu-api=vulkan
vulkan-swap-mode=mailbox

# PERFORMANCE BENCHMARK
video-sync=display-desync
osd-msg1="FPS: ${estimated-display-fps}"

image

Can't check without Vulkan as it seems it is locked to screen refresh rate. But maybe you can tell me how to do it with additional details as you did.

Btw, your youtube link just crashes my mpv.

[Edit] I pondered your question some more.

Are them rendered in scaled resolution?

It seems this is the key question. There is not sufficient performance (quiet unbelievable) to keep stable fps in gpu-hq in fullscreen. The video render size seems different depending on the window size. So the most impact is visible in fullscreen (requiring 4k resolution).

I will test some more "today" during the day.

haasn commented 2 years ago

Wait, why are you using vulkan-swap-mode=mailbox on X11? You should be using fifo!

Traneptora commented 2 years ago

Did using --vulkan-swap-mode=fifo fix the issue?

andyzukunft commented 2 years ago

I changed mode from mailbox to fifo and it provides more performance now. Just to be safe I removed profile=gpu-hq because it was at the limit for 4k video. The problem is I can't benchmark properly because fifo provides vsync just as the default configuration (without specifying gpu-api=vulkan).

As far as I can tell it looks like this: hwdec=nonon-vulkan (perhaps opengl?) > vulkan,fifo > vulkan,mailbox

Thanks for your help. I have one more question before closing the thread. Is using video-sync=display-resample sufficient or is it still recommended to set the display frame rate to n-times (int) the video frame rate?

Traneptora commented 2 years ago

If the monitor refresh rate is sufficiently large I don't see that being helpful. 120 Hz should be fine, just make sure you enable interpolation.

andyzukunft commented 2 years ago

I have to retract some of my statements. It seems one of the TV changes (the input type naming) actually enabled some image processing in the TV. That's the reason the video was smooth / the judder was removed.

If I deactivate the TV settings (again), the video returns to being judder-heavy. It doesn't matter whether I use Vulkan or not, whether the display refresh rate is set to 24, 60 or 120 Hz or whether I try to counter with video-sync=display-resample or autospeed.

amariami commented 11 months ago
  1. configuring video-sync=display-resample changes the behaviour, stuttering less often however with a far more annoying frame drop

Comparing the Vram buffer set in the BIOS 512MB vs 1024MB vs 2048MB vs 4096MB on Ryzen Mobile APU with AMD 23.9.3 driver I get a lot of framedrop when the Vram allocation resource is maxed out. If there's still a lot of Vram left, the result is zero framedrop except when switching into different resolution it's strange.

--vo=gpu-next --gpu-api=vulkan --hwdec=vulkan --vulkan-swap-mode=fifo --video-sync=display-resample --osd-msg1="FPS: ${estimated-display-fps} Output: ${frame-drop-count}"
specs32 commented 1 month ago

I also have an AMD CPU with iGPU running EOS and tearing/ judder problems, but only when in fullscreen (double click mpv window) this tearing does not appear when I have mpv in a window !

so my quick and dirty workaround is to remove titlebar and borders and maximize the window, looks the same like fullscreen without the tearing..

Haruna for example has no issue playing same video in fullscreen, as I understand it uses libmpv.. don't know what they do differently ..

(I am using the default mpv config for video)

Greetings !