mpv icon indicating copy to clipboard operation
mpv copied to clipboard

audio goes silent after skipping/fast forward/fast backward

Open mitzsch opened this issue 1 year ago • 9 comments

mpv Information

[   0.001][v][cplayer] mpv v0.39.0-24-g53f2619d Copyright Ā© 2000-2024 mpv/MPlayer/mplayer2 projects
[   0.002][v][cplayer]  built on Sep 27 2024 00:12:05
[   0.002][v][cplayer] libplacebo version: v7.349.0 (v7.349.0-13-ga018ab0-dirty)
[   0.002][v][cplayer] FFmpeg version: N-117212-g01c47dd23
[   0.002][v][cplayer] FFmpeg library versions:
[   0.002][v][cplayer]    libavcodec      61.20.100
[   0.002][v][cplayer]    libavdevice     61.4.100
[   0.002][v][cplayer]    libavfilter     10.5.100
[   0.002][v][cplayer]    libavformat     61.8.100
[   0.002][v][cplayer]    libavutil       59.40.100
[   0.002][v][cplayer]    libswresample   5.4.100
[   0.002][v][cplayer]    libswscale      8.4.100

Other Information

- Windows version: Windows 11 - Microsoft Windows NT 10.0.22631.0/22631.4169
- GPU model, driver and version: RTX3060 TI - Game Ready - 565.90
- Source of mpv: shinchiro
- Introduced in version: not known

Reproduction Steps

Open a movie file fast forward/fast backward many times, and/or click randomly in the OSD at different spots in the timeline. After doing this multiple times the audio goes silent.

In the log, these lines get printed:

[  30.381][v][cplayer] delaying audio start 2231.376979 vs. 2230.061000, diff=1.315979
[  30.424][v][cplayer] delaying audio start 2231.376979 vs. 2230.103000, diff=1.273979
[  30.466][v][cplayer] delaying audio start 2231.376979 vs. 2230.145000, diff=1.231979
[  30.507][v][cplayer] delaying audio start 2231.376979 vs. 2230.186000, diff=1.190979
[  30.548][v][cplayer] delaying audio start 2231.376979 vs. 2230.228000, diff=1.148979
[  30.590][v][cplayer] delaying audio start 2231.376979 vs. 2230.270000, diff=1.106979
[  30.633][v][cplayer] delaying audio start 2231.376979 vs. 2230.311000, diff=1.065979
[  30.673][v][cplayer] delaying audio start 2231.376979 vs. 2230.353000, diff=1.023979
[  30.715][v][cplayer] delaying audio start 2231.376979 vs. 2230.395000, diff=0.981979
[  30.757][v][cplayer] delaying audio start 2231.376979 vs. 2230.437000, diff=0.939979
[  30.799][v][cplayer] delaying audio start 2231.376979 vs. 2230.478000, diff=0.898979
[  30.840][v][cplayer] delaying audio start 2231.376979 vs. 2230.520000, diff=0.856979
[  30.883][v][cplayer] delaying audio start 2231.376979 vs. 2230.562000, diff=0.814979
[  30.925][v][cplayer] delaying audio start 2231.376979 vs. 2230.603000, diff=0.773979
[  30.965][v][cplayer] delaying audio start 2231.376979 vs. 2230.645000, diff=0.731979
[  31.008][v][cplayer] delaying audio start 2231.376979 vs. 2230.687000, diff=0.689979
[  31.049][v][cplayer] delaying audio start 2231.376979 vs. 2230.729000, diff=0.647979
[  31.091][v][cplayer] delaying audio start 2231.376979 vs. 2230.770000, diff=0.606979
[  31.133][v][cplayer] delaying audio start 2231.376979 vs. 2230.812000, diff=0.564979
[  31.174][v][cplayer] delaying audio start 2231.376979 vs. 2230.854000, diff=0.522979
[  31.216][v][cplayer] delaying audio start 2231.376979 vs. 2230.895000, diff=0.481979
[  31.257][v][cplayer] delaying audio start 2231.376979 vs. 2230.937000, diff=0.439979
[  31.300][v][cplayer] delaying audio start 2231.376979 vs. 2230.979000, diff=0.397979
[  31.341][v][cplayer] delaying audio start 2231.376979 vs. 2231.020000, diff=0.356979
[  31.383][v][cplayer] delaying audio start 2231.376979 vs. 2231.062000, diff=0.314979
[  31.425][v][cplayer] delaying audio start 2231.376979 vs. 2231.104000, diff=0.272979
[  31.467][v][cplayer] delaying audio start 2231.376979 vs. 2231.146000, diff=0.230979
[  31.508][v][cplayer] delaying audio start 2231.376979 vs. 2231.187000, diff=0.189979
[  31.549][v][cplayer] delaying audio start 2231.376979 vs. 2231.229000, diff=0.147979
[  31.591][v][cplayer] delaying audio start 2231.376979 vs. 2231.271000, diff=0.105979
[  31.633][v][cplayer] delaying audio start 2231.376979 vs. 2231.312000, diff=0.064979
[  31.680][v][cplayer] delaying audio start 2231.376979 vs. 2231.354000, diff=0.022979
[  31.716][v][cplayer] starting audio playback
[  31.716][v][cplayer] audio draining
[  31.716][d][ao/wasapi] Thread Resume
[  31.716][d][ao/wasapi] Thread Reset
[  31.716][d][ao/wasapi] Thread Pause
[  31.716][v][cplayer] audio EOF reached

Sometimes the audio comes back after the diff= goes to zero but in my testing, most of the time, the audio stays silent after the diff counter goes to zero. The log also indicates "audio EOF reached" which is not true.

I tested an older version of mpv that I had lying around on my PC. That does not exhibit this behavior. (mpv v0.37.0-766-ge42a8d53)

Expected Behavior

Fast forward/fast backward as many often as you want, without losing audio.

Actual Behavior

Fast forward/fast backward very often, audio playback is lost.

Log File

mpv-scrub-audio-out_new.txt

Snipped of a log on a different file with a DTS-HD track

audio-delay-after-skip.txt

Log of old mpv that does not show this issue:

mpv-scrub-audio-out_olderV.txt

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • [X] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [X] I provided all required information including system and mpv version.
  • [X] I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • [X] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [X] I attached the full, untruncated log file.
  • [X] I attached the backtrace in the case of a crash.

mitzsch avatar Oct 01 '24 16:10 mitzsch

Can you upload the audio track?

llyyr avatar Oct 01 '24 16:10 llyyr

unfortunately, I'm not allowed to upload that track... copyright. I will do some more testing, maybe I can find the version that introduced that behavior.

mitzsch avatar Oct 01 '24 17:10 mitzsch

I have a similar problem, after adjusting the progress, the video stutters, the audio is fine, and sometimes the video is fine but there is no sound. Error reported: 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). Consider trying --profile=fast and/or --hwdec=auto-safe as they may help.

There is no problem with the hardware The cpu is not occupied Files are played using PotPlayer without this problem The parameter ā€œprofile=fast,hwdec=auto-safeā€ was use

I use mpv.dll from this page https://github.com/shinchiro/mpv-winbuild-cmake/releases When I switch to the old 20240720 version of mpv.dll there is also no problem

I only found this problem on a highly compressed 4K mkv video.

fir05 avatar Oct 03 '24 16:10 fir05

I did some further investigation - with the limited old builds I have I could track it down to a change between build "a3baf94" (18.08.2024) and "e3a9ce2" (22.08.2024)

However, there does not seem to be a change that could affect it on mpvs side.

While debugging this message

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).
Consider trying --profile=fast and/or --hwdec=auto-safe as they may help.

also got printed from time to time.

I only found this problem on a highly compressed 4K mkv video.

On my end, it also only shows up on 4K HEVC files.

Now I assume its something with FFmpeg - between the commits "https://github.com/ffmpeg/FFmpeg/commit/5c1c0325cd1bd3f826bbd73dffd0b07974a586bd" and "https://github.com/ffmpeg/FFmpeg/commit/9d15fe77e33b757c75a4186fa049857462737713"

There are multiple HEVC-related commits... Debugging them is way ahead of my skills.

mitzsch avatar Nov 03 '24 15:11 mitzsch

If you can't share a sample and also can't bisect then I'm at a loss for how to proceed here. I guess you can create a sample if it happens with every 4k hevc sample?

llyyr avatar Nov 03 '24 15:11 llyyr

I will try to reproduce it with big Buck Bunny... The problem with a sample is that its not really on a specific spot and is more like happening randomly when skipping/rewinding...

mitzsch avatar Nov 03 '24 16:11 mitzsch

It seems to be this video file that triggers the issue: magnet:?xt=urn:btih:cd4c80cb6dfc825a8dc46a4fee6f14676127d8b4

I've been using the July version, but a couple of times I've tested the latest version and I've run into this problem. Looks like I'll be stuck with this July version for a long time.

fir05 avatar Nov 04 '24 10:11 fir05

Two months have passed and I downloaded the latest version and the problem still persists.

fir05 avatar Dec 27 '24 18:12 fir05

It's still an issue. I will try to compile some builds of MPV with the ffmpeg versions mentioned in one of my posts. Maybe I can track it down. On my end, it's now very easily reproducible with any 4K HEVC file... Open the file, let it play, skip backwards, and the chance is very high that you encounter this bug.

mitzsch avatar Jun 14 '25 12:06 mitzsch

This issue is also present on my end but I've so far only encountered it with files I've encoded with SVT-AV1 using FFMPEG. I was able to reproduce it with big buck bunny so here's a file that can be used to reproduce it. It was encoded with -c:v libsvtav1 -crf 25 -preset 7 -svtav1-params "enable-qm=1:qm-min=0:tune=2:scd=1:enable-variance-boost=1:variance-boost-strength=3:variance-octile=4" -c:a copy and this issue does not occur when playing the original h264 encoded file. This is on Arch Linux and the software versions I'm using are as follows:

cplayer] mpv v0.40.0-dirty Copyright Ā© 2000-2025 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Jul 14 2025 14:00:27
[cplayer] libplacebo version: v7.351.0
[cplayer] FFmpeg version: n7.1.1
[cplayer] FFmpeg library versions:
[cplayer]    libavcodec      61.19.101
[cplayer]    libavdevice     61.3.100
[cplayer]    libavfilter     10.4.100
[cplayer]    libavformat     61.7.100
[cplayer]    libavutil       59.39.100
[cplayer]    libswresample   5.3.100
[cplayer]    libswscale      8.3.100
Svt[info]: SVT [version]:       SVT-AV1 Encoder Lib v3.0.2-dirty

If there's anything else I can provide/test please let me know.

dbekatli avatar Jul 19 '25 13:07 dbekatli

Interesting to see it's also arising with AV1...

And it also shows the same "delayed audio start" message in the log?

[ 30.925][v][cplayer] delaying audio start 2231.376979 vs. 2230.603000, diff=0.77397

mitzsch avatar Jul 20 '25 09:07 mitzsch

Yes the log is spammed with that same message and the audio playback resumes once diff reaches 0. Forgot to attach the log, sorry.

[vo/gpu] Resize: 1280x720
[vo/gpu] Window size: 1280x720 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 1280x720 (1:1)
[vo/gpu] Video display: (0, 0) 1280x720 -> (0, 0) 1280x720
[vo/gpu] Video scale: 1.000000/1.000000
[vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[vo/gpu] Video borders: l=0 t=0 r=0 b=0
[vo/gpu] Reported display depth: 10
[vo/gpu] Assuming 165.080000 FPS for display sync.
[cplayer] audio ready
[cplayer] delaying audio start 0.000000 vs. 0.000000, diff=0.000000
[vo/gpu/wayland] Enabling idle inhibitor
[cplayer] playback restart complete @ 0.000000, audio=ready, video=playing
[cplayer] starting audio playback
[cplayer] Set property: user-data/osc/margins={"b":0,"r":0,"l":0,"t":0} -> 1
[cplayer] Set property: user-data/osc/margins={"b":0,"r":0,"l":0,"t":0} -> 1
[cplayer] Set property: user-data/osc/margins={"b":0,"r":0,"l":0,"t":0} -> 1
[osd/libass] fontselect: (sans-serif, 400, 0) -> /usr/share/fonts/noto/NotoSans-Regular.ttf, 0, NotoSans-Regular
[osd/libass] fontselect: (mpv-osd-symbols, 400, 0) -> mpv-osd-symbols-Regular, 0, mpv-osd-symbols-Regular
[vo/gpu] Reallocating OSD texture to 2048x128.
[mkv] queuing seek to 11.167000
[mkv] execute seek (to 11.167000 flags 4)
[mkv] Seeking to 148728947 to read header element 0x1c53bb6b.
[file] stream level seek from 655360 to 148728947
[mkv] Parsing cues...
[file] stream level seek from 148730817 to 3321467
[mkv] seek done
[vd] Decoder format: 1280x720 vaapi[nv12] bt.709/bt.709/bt.1886/limited/auto CL=uhd crop=1280x720+0+0
[vd] Using container aspect ratio.
[vo/gpu/wayland] Disabling the idle inhibitor
[osd/libass] libass API version: 0x1704000
[osd/libass] libass source: commit: 0.17.4-0-gbbb3c7f1570a4a021e52683f3fbdf74fe492ae84
[osd/libass] Shaper: FriBidi 1.0.16 (SIMPLE) HarfBuzz-ng 11.2.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
[osd/libass] fontselect: (sans-serif, 400, 0) -> /usr/share/fonts/noto/NotoSans-Regular.ttf, 0, NotoSans-Regular
[vo/gpu] Reallocating OSD texture to 1024x128.
[cplayer] first video frame after restart shown
[cplayer] audio ready
[cplayer] delaying audio start 21.013000 vs. 13.417000, diff=7.596000
[cplayer] playback restart complete @ 13.417000, audio=ready, video=playing
[vo/gpu/wayland] Enabling idle inhibitor
[cplayer] delaying audio start 21.013000 vs. 13.458000, diff=7.555000
[cplayer] delaying audio start 21.013000 vs. 13.500000, diff=7.513000
[cplayer] delaying audio start 21.013000 vs. 13.542000, diff=7.471000
[cplayer] delaying audio start 21.013000 vs. 13.583000, diff=7.430000
[cplayer] delaying audio start 21.013000 vs. 13.625000, diff=7.388000
[cplayer] delaying audio start 21.013000 vs. 13.667000, diff=7.346000
[cplayer] delaying audio start 21.013000 vs. 13.708000, diff=7.305000
[cplayer] delaying audio start 21.013000 vs. 13.750000, diff=7.263000
[cplayer] delaying audio start 21.013000 vs. 13.792000, diff=7.221000
[cplayer] delaying audio start 21.013000 vs. 13.833000, diff=7.180000
[cplayer] delaying audio start 21.013000 vs. 13.875000, diff=7.138000
[cplayer] delaying audio start 21.013000 vs. 13.917000, diff=7.096000
[cplayer] delaying audio start 21.013000 vs. 13.958000, diff=7.055000
[cplayer] delaying audio start 21.013000 vs. 14.000000, diff=7.013000
[cplayer] delaying audio start 21.013000 vs. 14.042000, diff=6.971000
[cplayer] delaying audio start 21.013000 vs. 14.083000, diff=6.930000
[cplayer] delaying audio start 21.013000 vs. 14.125000, diff=6.888000
[cplayer] delaying audio start 21.013000 vs. 14.167000, diff=6.846000
[cplayer] Set property: user-data/osc/margins={"b":0,"r":0,"l":0,"t":0} -> 1
[cplayer] delaying audio start 21.013000 vs. 14.208000, diff=6.805000
[cplayer] delaying audio start 21.013000 vs. 14.250000, diff=6.763000
[cplayer] delaying audio start 21.013000 vs. 14.292000, diff=6.721000
[cplayer] delaying audio start 21.013000 vs. 14.333000, diff=6.680000
[cplayer] delaying audio start 21.013000 vs. 14.375000, diff=6.638000
[cplayer] delaying audio start 21.013000 vs. 14.417000, diff=6.596000
[cplayer] delaying audio start 21.013000 vs. 14.458000, diff=6.555000
[cplayer] delaying audio start 21.013000 vs. 14.500000, diff=6.513000
[cplayer] delaying audio start 21.013000 vs. 14.542000, diff=6.471000
[cplayer] delaying audio start 21.013000 vs. 14.583000, diff=6.430000
[cplayer] delaying audio start 21.013000 vs. 20.833000, diff=0.180000
[cplayer] delaying audio start 21.013000 vs. 20.875000, diff=0.138000
[cplayer] delaying audio start 21.013000 vs. 20.917000, diff=0.096000
[cplayer] delaying audio start 21.013000 vs. 20.958000, diff=0.055000
[cplayer] delaying audio start 21.013000 vs. 21.000000, diff=0.013000
[cplayer] starting audio playback
[cplayer] EOF code: 5  

Some lines were removed to not take too much space, that's why it jumps from 6.4 to 0.18.

dbekatli avatar Jul 20 '25 10:07 dbekatli

Very interesting... Thanks for posting the logs!

Is it possible for you to test an old version of mpv and especially ffmpeg? (before August 2024)

I tried to track it down, but the commits I had suspected (the ones posted in my November comment) of causing the issue are HEVC-related. However, maybe some other commit between my suspected ones is the culprit.

mitzsch avatar Jul 20 '25 11:07 mitzsch

Tested these configurations, FFmpeg n7.1.1 - MPV 0.38, FFmpeg 6.1.2 - MPV 0.38, FFmpeg 6.1.2 - MPV 0.37, FFmpeg n4.4.6 - MPV 0.37. The issue still happens the exact same way. Tried to test 0.35 and 0.36 too but they immediately crash with ta_dbg_check_header: Assertion h->canary == CANARY failed..

I've also tested disabling hwdec, changing vo to wlshm, and tried out alsa, pulse, and pipewire as the audio output. The behavior is always the same. My theory was that it was tied to the keyframe interval but that is 5 seconds in the big buck bunny file I uploaded and diff starts from 7.55 so that doesn't seem to be the case. Does the issue occur on your end with that file too?

dbekatli avatar Jul 20 '25 14:07 dbekatli

Thanks for the quick testing!

I just downloaded that file and tried it on my end. I“m on Windows (11) and could immediately trigger that problem. I will also test older builds on my end... Thanks for providing a sample!

mitzsch avatar Jul 20 '25 15:07 mitzsch

Okay, update. This also happens in older builds. However, I tried remuxing the file and tested again. With Writing application: mkvmerge v93.0 ('Goblu') 64-bit, Writing library: libebml v1.4.5 + libmatroska v1.7.1, the file does not show the issue. Very interesting.

mitzsch avatar Jul 20 '25 15:07 mitzsch

Interesting, I tried opening the same file with VLC and it has a problem with the video instead. Audio plays fine in the background but displays a still frame. I would assume that ffmpeg is generating problematic files but ffplay can play the file and seek without any of these issues.

dbekatli avatar Jul 22 '25 18:07 dbekatli

Just encoded the same file with the exact same arguments but with an mp4 container instead of mkv and it plays fine without this issue.

dbekatli avatar Jul 22 '25 19:07 dbekatli

My MPV still occasionally suffers from stuttering and no audio. Today, I noticed that the official default-configured MPV does not have this issue.

I reviewed my MPV configuration, and the key parameters are:

profile = fast  
config = no  
vo = gpu  
hwdec = auto

My PC is mid-to-low end, and this was the best configuration I had found before.

However, after removing the config = no option, the stuttering and audio issues disappeared. The behavior is now consistent with the official version.

fir05 avatar Jul 22 '25 19:07 fir05

This issue is also present on my end but I've so far only encountered it with files I've encoded with SVT-AV1 using FFMPEG. I was able to reproduce it with big buck bunny so here's a file that can be used to reproduce it.

If you run

mkvinfo -s p1glqb.mkv | less

you will see that audio and video frames are not interleaved well. From the start, you get five seconds of video frames before the first audio frame. Remuxing with mkvmerge fixes this issue presumably because it interleaves the frames better.

This is a less extreme case of #12778, if with a different manifestation. The same workaround should work:

mpv $file -audio-file $file

MoSal avatar Jul 23 '25 15:07 MoSal

The file plays and seeks without problems with the workaround, thanks a lot. The file was created with ffmpeg without any muxing related options so I'm assuming this is an upstream ffmpeg issue?

dbekatli avatar Jul 23 '25 21:07 dbekatli

It feels like the AV1/MKV file problem is a different issue...

When I find some time, I will rebuild with old ffmpeg/mpv and retest with the HEVC files.

mitzsch avatar Jul 29 '25 16:07 mitzsch