mpv icon indicating copy to clipboard operation
mpv copied to clipboard

AVFoundation causes frame drops when resuming from an underrun state.

Open bitxeno opened this issue 7 months ago β€’ 5 comments

mpv Information

mpv v0.40.0-dev-gf9ec3d2c2 Copyright Β© 2000-2025 mpv/MPlayer/mplayer2 projects
 built on May 14 2025 13:53:42
libplacebo version: v7.349.0
FFmpeg version: 7.1.1
FFmpeg library versions:
   libavcodec      61.19.101
   libavdevice     61.3.100
   libavfilter     10.4.100
   libavformat     61.7.100
   libavutil       59.39.100
   libswresample   5.3.100
   libswscale      8.3.100

Other Information

- macOS version: macOS 15.1.1 
- Source of mpv: https://nightly.link/mpv-player/mpv/workflows/build/master
- Latest known working version: -
- Issue started after the following happened: -

Reproduction Steps

mpv --no-config  --input-commands='script-message display-stats-toggle'  --hwdec=yes  --ao=avfoundation [slow_url]

Expected Behavior

Don't drop frames when resuming from an underrun state.

Actual Behavior

When the playback URL is slow, the player pauses to buffer after underrun. However, resuming playback causes a drop of approximately 30 or more frames.

Log File

● Video  --vid=1  (h264 720x540 25 fps) [default]
● Audio  --aid=1  (aac 1ch 48000 Hz 16 kbps) [default]
Using hardware decoding (videotoolbox).
AO: [avfoundation] 48000Hz mono 1ch float
VO: [gpu] 720x540 videotoolbox[nv12]
AV: 00:00:00 / 00:23:43 (0%) A-V:  0.000 Cache: 0.0s/196KB2025-05-15 11:51:36.081 mpv[94746:20250838] +[IMKClient subclass]: chose IMKClient_Modern
2025-05-15 11:51:36.081 mpv[94746:20250838] +[IMKInputSession subclass]: chose IMKInputSession_Modern
Audio device underrun detected.

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` as they may help.

Audio device underrun detected.
Audio device underrun detected.
Audio device underrun detected.
Audio device underrun detected.
Audio device underrun detected.
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: stream 1, offset 0x3e6c7b: partial file
AV: 00:00:34 / 00:23:43 (2%) A-V:  0.000 Dropped: 184 Cache: 3.1s/759KB
Exiting... (Quit)

mpv_debug.log

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.

bitxeno avatar May 15 '25 04:05 bitxeno

does it happen without --hwdec=yes and --input-commands='script-message display-stats-toggle'? does it happen with vo=gpu-next?

on a side note, i would expect dropped frames in the case of audio and video desynchonising because of underruns.

what do you think @ruihe774?

Akemi avatar May 15 '25 14:05 Akemi

does it happen without --hwdec=yes and --input-commands='script-message display-stats-toggle'? does it happen with vo=gpu-next?

on a side note, i would expect dropped frames in the case of audio and video desynchonising because of underruns.

what do you think @ruihe774?

Frame drops also occur without --hwdec=yes and --input-commands='script-message display-stats-toggle' or with vo=gpu-next.

This issue is related to --ao=avfoundation.

bitxeno avatar May 16 '25 01:05 bitxeno

Yes, frame drop is possible (and sometimes common) when filling the audio buffer. This is an intrinsic issue. For example, when you play audio in Safari (especially with your AirPods and Spatial Audio on), you also notice a lag of audio and video when switching between different playback speeds. If you deliberately don’t want this, you may try other --video-sync options (may work or may not).

Get Outlook for iOShttps://aka.ms/o0ukef


From: der richter @.> Sent: Thursday, May 15, 2025 10:53:26 PM To: mpv-player/mpv @.> Cc: Rui He @.>; Mention @.> Subject: Re: [mpv-player/mpv] AVFoundation causes frame drops when resuming from an underrun state. (Issue #16346)

[https://avatars.githubusercontent.com/u/680386?s=20&v=4]Akemi left a comment (mpv-player/mpv#16346)https://github.com/mpv-player/mpv/issues/16346#issuecomment-2884126081

does it happen without --hwdec=yes and --input-commands='script-message display-stats-toggle'? does it happen with vo=gpu-next?

on a side note, i would expect dropped frames in the case of audio and video desynchonising because of underruns.

what do you think @ruihe774https://github.com/ruihe774?

― Reply to this email directly, view it on GitHubhttps://github.com/mpv-player/mpv/issues/16346#issuecomment-2884126081, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A4GNBYYQMAHH3FCXYVTYNZD26SS6LAVCNFSM6AAAAAB5E7JQ5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBUGEZDMMBYGE. You are receiving this because you were mentioned.Message ID: @.***>

ruihe774 avatar May 16 '25 01:05 ruihe774

I tried the --video-sync=display-resample option, but still experiencing frame drops.

If this is an intrinsic issue, I'll ignore it. Thanks.

bitxeno avatar May 16 '25 03:05 bitxeno

No, you should keep this open, in case someone comes up with a novel solution.

Get Outlook for iOShttps://aka.ms/o0ukef


From: bitxeno @.> Sent: Friday, May 16, 2025 11:24:49 AM To: mpv-player/mpv @.> Cc: Rui He @.>; Mention @.> Subject: Re: [mpv-player/mpv] AVFoundation causes frame drops when resuming from an underrun state. (Issue #16346)

[https://avatars.githubusercontent.com/u/137328844?s=20&v=4]bitxeno left a comment (mpv-player/mpv#16346)https://github.com/mpv-player/mpv/issues/16346#issuecomment-2885534650

I tried the --video-sync=display-resample option, but still experiencing frame drops.

If this is an intrinsic issue, I'll ignore it. Thanks.

― Reply to this email directly, view it on GitHubhttps://github.com/mpv-player/mpv/issues/16346#issuecomment-2885534650, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A4GNBY6Y4HETKVDXPYLHG5T26VLADAVCNFSM6AAAAAB5E7JQ5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBVGUZTINRVGA. You are receiving this because you were mentioned.Message ID: @.***>

ruihe774 avatar May 16 '25 04:05 ruihe774