-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
-ao pulse
causes visual jerkiness for 20 seconds after unpause
#12057
Comments
0.35.x and older are unsupported, please re-test with 0.36.0. |
Done. The problem also exists in 0.36.0. |
I did not expect to be able to reproduce on an AMD system but I can. |
Without display-resample, I still see lots of jumpiness in the video. It seems like about the same amount, to me, though it's not as easy to measure. |
Doing the following diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index ae19c875c0..d7644e0abc 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -633,6 +633,10 @@ static void audio_get_state(struct ao *ao, struct mp_pcm_state *state)
state->playing = priv->playing;
+ MP_ERR(ao, "free=%d queued=%d delay=%.4f play=%d\n", state->free_samples,
+ state->queued_samples, state->delay,
+ !!state->playing);
+
pa_threaded_mainloop_unlock(priv->mainloop);
// Otherwise, PA will keep hammering us for underruns (which it does instead it is apparent that PA returns too high latency values twice after unpausing: AV: 00:00:04 / 00:24:10 (0%) A-V: -0.003 DS: 3.620/5 Dropped: 1 [ao/pulse] free=0 queued=4410 delay=0.1349 play=1 [ao/pulse] free=0 queued=4410 delay=0.1206 play=1 [ao/pulse] free=1765 queued=2645 delay=0.1205 play=1 AV: 00:00:04 / 00:24:10 (0%) A-V: -0.003 DS: 3.590/5 Dropped: 1 [ao/pulse] free=0 queued=4410 delay=0.1598 play=1 [ao/pulse] free=0 queued=4410 delay=0.1347 play=1 [ao/pulse] free=1766 queued=2644 delay=0.1204 play=1 [ao/pulse] free=0 queued=4410 delay=0.1599 play=1 [ao/pulse] free=0 queued=4410 delay=0.1515 play=1 (Paused) AV: 00:00:04 / 00:24:10 (0%) A-V: -0.003 DS: 3.590/5 Dropped: 1 [ao/pulse] free=0 queued=4410 delay=4.6162 play=1 [ao/pulse] free=0 queued=4410 delay=4.6162 play=1 Audio/Video desynchronisation detected! Possible reasons include too slow hardware, temporary CPU spikes, broken drivers, and broken files. Audio position will not match to the video (see A-V status field). AV: 00:00:04 / 00:24:10 (0%) A-V: -4.474 DS: 3.550/5 Dropped: 1 [ao/pulse] free=0 queued=4410 delay=0.1453 play=1 AV: 00:00:04 / 00:24:10 (0%) A-V: 0.473 DS: 3.820/5 Dropped: 1 [ao/pulse] free=0 queued=4410 delay=0.1260 play=1 [ao/pulse] free=1774 queued=2636 delay=0.1202 play=1 [ao/pulse] free=0 queued=4410 delay=0.1601 play=1 AV: 00:00:04 / 00:24:10 (0%) A-V: 0.473 DS: 3.820/5 Dropped: 1 [ao/pulse] free=0 queued=4410 delay=0.1350 play=1 [ao/pulse] free=1766 queued=2644 delay=0.1204 play=1 [ao/pulse] free=0 queued=4410 delay=0.1599 play=1 [ao/pulse] free=0 queued=4410 delay=0.1347 play=1 AV: 00:00:04 / 00:24:10 (0%) A-V: 0.473 DS: 3.820/5 Dropped: 1 [...] This causes A-V desync that lasts for a bit, matching what you described. As such I think this is a duplicate of #10333. This issue also goes away reliably when you use The only notable fact is that you say mpv 0.32.0 can do it correctly on your system. This hints at this being not PA bug but a problem in how mpv uses PA. |
Yes. On my machine, before and after d27ad96 is like night and day. If bugs only show themselves during the day. |
I'd like to add the feedback that this is a very high priority issue, the stuttering after unpausing makes mpv the worst video player. If reverting d27ad96 is not realistic due to the large amount of work done, then I suggest temporarily switching the default ao to alsa, that's what I did on my config to make mpv the best video player again. Temporarily printing a warning in console when using pulseaudio ao is another good idea, I suggest doing both. |
No need for all that when you can just use |
Is it worth making that the default? |
I was planning to propose that, yes. IIRC it was the default before during another time when PA was buggy. |
This is how I've worked around the issue for now. It resolves the issue on both of the systems I use |
It was disabled in 2015 |
As far as I can tell PulseAudio introduced a bug in 16.0 where if a stream is (un)paused too often the reported latency will momentarily spike by 3000% or more. Apparently in certain cases just pausing once and waiting can also cause this. Save the remaining users of PA the trouble of debugging the various obscure issues that can arise from this (desync is a harmless example) by enabling the latency hack code again. ref: <mpv-player#12057> <mpv-player#10333>
As far as I can tell PulseAudio introduced a bug in 16.0 where if a stream is (un)paused too often the reported latency will momentarily spike by 3000% or more. Apparently in certain cases just pausing once and waiting can also cause this. Save the remaining users of PA the trouble of debugging the various obscure issues that can arise from this (desync is a harmless example) by enabling the latency hack code again. ref: <#12057> <#10333>
Thanks for the fix! |
Important Information
0.33.0
and newer (tested up to0.35.1
)0.33.0
xfce
nvidia 525.125.06-1
Reproduction steps
simplest config possible:
more scientific reproducer (with numbers!)
--video-sync=display-resample
)When I type in the
Mistimed
numbers I see, every time the stats overlay refreshes, I get a sequence like this:1 6 15 28 41 51 67 75 87 103 109 114 116 119 122 122 124 125 125 125
After that it settles down. It seems the worst delays are about 5 seconds after the unpause... for whatever that's worth.
Expected behavior
Playback is smooth after unpause.
Actual behavior
Playback is visually jerky for about 20 seconds after unpause. "Mistimed:" counter increases by about 10 every time the stats screen updates. After about 20 seconds, it settles down and playback seems fine.
Log file
mpv-jerky-video.txt
More info
It seems like the pause needs to last at least 7 seconds in order to trigger the issue. A 10 second pause is a completely reliable reproducer. It happens 100% of the time I try it, on 100% of the video files I've tried.
I started noticing this issue at around version 0.34.0. The previous version of Debian (bullseye) has an older package of
mpv_0.32.0-3_amd64.deb
which I can install on this bookworm system, leaving all of the dependencies alone, and it works fine. (Installs fine, it plays back fine, pauses and resumes fine.)I was able to
git bisect
this issue, working around a few build issues along the way, and found initially that it fails in 0.33.0 and works in 0.32.0. I further narrowed it down to d27ad96. That commit expresses some concern about the stability of-ao pulse
; I guess this is the evidence.Seeing that the issue was audio related, I did some more testing and found:
-ao pulse
: visual stuttering after pause-ao pulse --pulse-latency-hacks=yes
: seems fine-ao alsa
: seems fine-ao sdl
: seems fineThe commit message recommends alsa, and alsa does work, but mpv seems to use pulse by default.
This bug report might be a more specific version of #10954 or it might be unrelated; hard to be sure.
The text was updated successfully, but these errors were encountered: