mpv-player / mpv

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

looped files (--loop) stutter between loops on vulkan #13924

Open Rabcor opened 2 months ago

Rabcor commented 2 months ago

Reproduction steps

mpv --no-config --gpu-api=vulkan --loop perfect-loop.gif

It is easiest to see the stutter on perfectly looping low-framerate short (~1-2s) animations. It does not have to be any particular format (e.g. it's the same if it's mp4 or gif)

Expected behavior

Seamless looping

Actual behavior

Stutters at the start/end of each loop. I believe it might be skipping the first or last frame.

Possible relation to this issue: #2745

Log file

output.txt

Sample files

The issue is fairly easy to see with this GIF. 5xtDary2ULj8lEba812

Edit: Higher framerate sample file https://giphy.com/gifs/daily-after-effects-hypnotic-oO95KMJ7LqZxdh66pY (it can be more noticable with this)

Edit2: I recorded the effect for people who don't want to test it themselves, do note it is most visible in the top animation and least in the lowest one (I believe it has to do with the framerate they were animated at), after showing how it is in mpv, I alt tabbed into qimgv for comparison:

https://github.com/mpv-player/mpv/assets/5684325/572caf24-a73b-4335-8376-48fd8bafae5e

guidocella commented 2 months ago

Probably fixed by https://github.com/mpv-player/mpv/pull/10748

Dudemanguy commented 2 months ago

I don't see any stutter on my end.

Rabcor commented 2 months ago

I don't see any stutter on my end.

:thinking: interesting, are you on X11 or Wayland?

Dudemanguy commented 2 months ago

I tried both and I don't see anything. But maybe I'm just blind.

Rabcor commented 2 months ago

I tried both and I don't see anything. But maybe I'm just blind.

I just tried on X11 too, it stuttered there but I feel like it was less obvious than on Wayland.

it is just 1 frame tho I think, but to me it's blatantly obvious, did you try playing it side-by-side with the opengl renderer on one instance (or maybe even just your browser)? it might be easier to spot the difference if you have a perfectly smooth sample beside it for comparison.

kasper93 commented 2 months ago

Are you able to test with #10748 changes?

Rabcor commented 2 months ago

Are you able to test with #10748 changes?

I wouldn't be averse to trying, but I really don't know how, I can barely manage to wrangle pkgbuilds into building specific versions from git for me if I have like 20 minutes to do it, never mind applying unapplied pull requests (e.g. patches).

But I have actually managed adding patches to aur packages before (and I suppose there's also the option of applying them and building from git but it's not like using makepkg is any harder really) so maybe if I had a prepared patch that's compatible with the current git master I could manage it... But that PR is from 2022, so I doubt it'll be very easy to get that.

Also, this file can serve as an alternate sample, it's bigger and higher framerate so it's a little easier to notice with this file.

Might be worth a try for you to use this file instead @Dudemanguy

https://giphy.com/gifs/daily-after-effects-hypnotic-oO95KMJ7LqZxdh66pY

With this file I noticed there actually is a stutter in the opengl renderer between loops as well, but if the vulkan renderer stutter is a normal stutter, the one in the opengl renderer is a microstutter (had to really be looking hard for it to see it; I think it's only visible at all due to the high framerate, I cannot see any stutter on the opengl renderer in the OP sample pic)

guidocella commented 2 months ago

I also can't reproduce the stutter on either video on either Vulkan or a 2011 laptop.

kasper93 commented 2 months ago

if I had a prepared patch that's compatible with the current git master I could manage it... But that PR is from 2022, so I doubt it'll be very easy to get that.

According to github there are no conflicts, you can use this patch directly https://github.com/mpv-player/mpv/pull/10748.patch

Dudemanguy commented 2 months ago

Might be worth a try for you to use this file instead @Dudemanguy https://giphy.com/gifs/daily-after-effects-hypnotic-oO95KMJ7LqZxdh66pY

I can see it here I think. opengl looks fine to me.

10748 seems to completely break the duration of gifs at least but it does work.

Rabcor commented 2 months ago

if I had a prepared patch that's compatible with the current git master I could manage it... But that PR is from 2022, so I doubt it'll be very easy to get that.

According to github there are no conflicts, you can use this patch directly https://github.com/mpv-player/mpv/pull/10748.patch

Yep, getting same result as Dudemanguy. It fixes the stutter, but it breaks the duration of gifs, although i think that is pretty much how it works maybe (instead of starting the file over, it keeps playing the file in a continuous stream).

I also took a look to see if there was a performance difference, performance didn't change at all from using the patch.

Honestly if the duration thingy is fixed, that code might be good to use as default for --loop/--loop-file, using a --seamless-looping setting seems like nonsense.

Rabcor commented 2 weeks ago

I added a recording to the op of the effect