mpv-player / mpv

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

Inconsistent Audio Delay When Starting Video Playback #11446

Open WesToleman opened 1 year ago

WesToleman commented 1 year ago

I'm running mpv on a home-theatre PC connected to a TV through a receiver. I'm using a Sync-One2 to measure audio-delay so I can add an audio-delay=… to my mpv.conf. I am experiencing a bug where the reported delay is different for each launch of mpv or when resuming playback from pause. There's no drift during playback; the timing remains steady (within a couple of ms) when playing video. The delay is just different each time I start playback.

System information

OS: Linux Mint 21.1 x86_64 
Kernel: 5.19.0-35-generic 
CPU: Intel i3-10100F (8) @ 4.300GHz 
GPU: NVIDIA GeForce GT 1030
Window Manager: Cinnamon 5.6.7
NVidia Driver: 525.85.05
ALSA v: k5.19.0-35-generic

I'm using a mpv that I built on this system using mpv-build and the steps for Debian packages

mpv 0.35.0-317-g9880b06a37 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
 built on Mon Mar 13 09:30:36 2023
libplacebo version: v5.264.0-rc1-4-g61a9f2bf
FFmpeg version: N-110002-g7c130d6911
FFmpeg library versions:
   libavutil       58.3.100
   libavcodec      60.6.101
   libavformat     60.4.100
   libswscale      7.2.100
   libavfilter     9.4.100
   libswresample   4.11.100

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

  1. Measure audio delay using the measurement process for the Sync-One2 specified in its manual.
  2. Pause video playback and then resume or re-launch mpv
  3. Observe a different delay amount

This issue is still reproducible with only the output device configured.

pasuspender -- \
mpv \
--no-config \
--load-scripts=no \
--audio-device=alsa/hdmi:CARD=NVidia,DEV=0 \
--audio-channels=7.1,5.1,stereo \
--fullscreen \
--log-file=/tmp/sync-log.log \
Sync-One2_Test_1080p_23.98_HEVC_PCM_5.1.mov

Expected behavior

Every launch of mpv or resume of video playback has the same audio delay.

Actual behavior

The audio delay varies between runs of mpv or after resuming playback. The variations are multiple 10s of ms so quite noticeable.

Log file

Log file

Sample files

Using the standard Sync-One2 test files

mitzsch commented 1 year ago

Does it change when you use hw decoding? Have you tried different sync modes? https://mpv.io/manual/master/#options-video-sync Does the Sync-One2 work with different syncing files - if so maybe try a different one? I´m curious if mpv on windows shows the same behavior....

WesToleman commented 1 year ago

Does it change when you use hw decoding?

I appears to be unaffected by hardware decoding

Have you tried different sync modes?

I just tried all the options listed in the manual. All of the modes exhibit the issue. The playback of some seemed to be less stable than others. The desync options generated the desynchronisationd detected warning message.

I´m curious if mpv on windows shows the same behavior....

I'll have to see if I can get the Windows laptop set up. I was starting to question my gear so I compared Kodi, it seemed pretty good but I'm not sure if it's using CEC to cheat.

mitzsch commented 1 year ago

Good to know, that hw decoding and different sync modes have no effect on that one!

May I ask if the experience is different when using pulseaudio?

Thanks for trying to get it tested on windows, if it works there - then its something Linux mpv audio out related and not something mpv internal before output. CEC shouldn´t be involved in this, as almost any pc hardware is not cec capable.

WesToleman commented 1 year ago

May I ask if the experience is different when using pulseaudio?

I tried Pulse briefly, I believe it still had issues. I can't test extensively because I've replaced it with PipeWire.

CEC shouldn´t be involved in this, as almost any pc hardware is not cec capable.

I've got a PulseEight Adapter on this system.