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

Increasing playback speeds and seeking during high speeds causes high av desynchronisation and gaps in audio #13613

Closed
mesvam opened this issue Mar 2, 2024 · 10 comments

Comments

@mesvam
Copy link

mesvam commented Mar 2, 2024

Important Information

Provide following Information:

If you're not using git master or the latest release, update.
Releases are listed here: https://github.com/mpv-player/mpv/releases

Reproduction steps

Set the following keybinds in input.conf

1 set speed 1
2 set speed 2
3 set speed 4
4 set speed 8
5 set speed 16

Play a file that has both video and audio. (Behavior does not happen on audio-only files). Use keybinds to increase the speed, then seek backwards and forwards. Repeat increasing the speed until desynchronization warning appears.

Also pay attention to the duration of the gap in the audio, or optionally record the played audio using another software.

Actual behavior

  • "Audio/Video desynchronisation detected!" warning appears upon seeking at 4x speed or higher, even if --profile=fast and/or --hwdec=auto-safe is added
  • There is a large (~200ms) gap in the audio upon seeking (measured using audio recording)
  • When speed is changed, the A-V indicator on the command line status immediately increases to a high value (>600ms desync), then slowly decreases over ~1-2s. The desync is noticeable by visual inspection

Expected behavior

In previous versions

  • You could go up to 8x and even 16x without desynchronization
  • There is a small (~35ms) gap in the audio upon seeking (measured using audio recording)
  • When speed is changed, the A-V indicator on the command line status only changes slightly (<25ms desync) and quickly decreases down to 0

Log file

mpv.log

Sample files

Issue applies to any file, but can use this test file with a continuous 1000Hz tone (Volume warning! Loud!): https://github.com/mpv-player/mpv/assets/14833020/4186eb16-98e7-4040-b894-e1368fb49431

@mesvam mesvam changed the title Seeking during high playback speeds causes av desynchronisation and gaps in audio Increasing playback speeds and seeking during high speeds causes high av desynchronisation and gaps in audio Mar 2, 2024
@Dudemanguy
Copy link
Member

Two problems here. One, I did not adjust the pts calculation in audio_start_ao which should have been done in 7051e94. Second, the MIN_PAST_FRAMES check is simply too broad and catches when it shouldn't.

@Dudemanguy
Copy link
Member

Could you try the build here?

@quietvoid
Copy link
Contributor

I'm still getting a stutter when changing the speed on #13614, and it doesn't happen on 74b4c3c.

@Dudemanguy
Copy link
Member

Just to be clear, when you say stutter do you mean visually or an audio one?

@quietvoid
Copy link
Contributor

It's visual only for me.

@Dudemanguy
Copy link
Member

OK, yeah that makes sense. The cost of not immediately adjusting av sync to avoid skipping frames results in some visual stutter on the speed change. I'll see if maybe I can smooth it out over the next few frames to make it more imperceptible.

@mesvam
Copy link
Author

mesvam commented Mar 2, 2024

Is it possible to just start both the video and audio in sync? I don't understand why av sync is affected by speed or seeking?

@Dudemanguy
Copy link
Member

Is it possible to just start both the video and audio in sync?

It would be nice if it was that simple. Audio and video can start from different positions including after a seek. When you change speed, you modify both the video and audio timings so you have to make sure the sync is still correct.

@mesvam
Copy link
Author

mesvam commented Mar 3, 2024

Yea, I figured it had to be more complicated than that.

I tried the build and video lags a bit, but audio is continuous now.

@mesvam
Copy link
Author

mesvam commented Mar 3, 2024

I'll note that --mc=1 mitigates ~80% of the ill effects of this, just subjectively

xrun1 pushed a commit to xrun1/mpv-svp-fix that referenced this issue Mar 12, 2024
Ended up being too flawed and caused trouble in other areas. There's
other approaches to trying to solve the issue this meant to address in
the works that should be better, so let's wait on that. Fixes mpv-player#13613 and
fixes mpv-player#13622.

This reverts commit e3af545.
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

3 participants