Skip to content

Switching audio devices from macOS causes dropped frames when using AVFoundation #18412

Description

@Uranosphaerite

mpv Information

mpv v0.41.0 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.360.1
FFmpeg version: 9.0 (runtime 9.0.1)
FFmpeg library versions:
   libavcodec      63.1.100 (runtime 63.1.101)
   libavdevice     63.1.100 (runtime 63.1.101)
   libavfilter     12.1.100 (runtime 12.1.101)
   libavformat     63.1.100 (runtime 63.1.101)
   libavutil       61.1.100 (runtime 61.1.101)
   libswresample   7.1.100 (runtime 7.1.101)
   libswscale      10.1.100 (runtime 10.1.101)

Other Information

- macOS version: macOS 27.0 (26A5421a)
- Source of mpv: Homebrew
- Latest known working version: unknown
- Issue started after the following happened: started testing AVFoundation

Screen Recording:
https://github.com/user-attachments/assets/da5ae3a4-0d47-4af3-aceb-f9b20d7c833b

Reproduction Steps

  1. Run mpv --no-config --ao=avfoundation file
  2. Press shift+i to show playback statistics
  3. With autoselect as the audio device, switch sound outputs from the menu bar or sound settings (I did this between my MacBook speakers and AirPods)
  4. Note the "Dropped Frames" statistic. Every time I switch audio devices, 30-40 frames are dropped and the effect on the video is very noticeable.

In the console, mpv returns

[ao/avfoundation] restarting due to system notification; this will cause desync
                                         
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.

No combination of --profile=fast and --hwdec=auto causes any change in behavior.

This behavior happens in IINA too (libmpv)

When using my AirPods, macOS shows "Multichannel" in the sound menu. Since I don't have a second device without Spatial Audio support to test on, I'm unsure if switching between 2 devices that are both stereo only would still cause the issue.


Doing the same steps but switching audio devices from inside MPV still causes dropped frames when switching between avfoundation audio devices. However, only 0-2 frames are dropped and the impact is much smaller.

Expected Behavior

No frames should be dropped, like with CoreAudio

Actual Behavior

30 to 40 frames are dropped, with a noticeable effect on the video

Log File

mpvlog.txt

Sample Files

https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_1080p_h264.mov.zip

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

  • I tested and confirmed that the issue exists with the latest release version or newer.
  • I provided all required information including system and mpv version.
  • 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.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions