Switching audio devices from macOS causes dropped frames when using AVFoundation
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
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
- Run
mpv --no-config --ao=avfoundation file - Press shift+i to show playback statistics
- With
autoselectas the audio device, switch sound outputs from the menu bar or sound settings (I did this between my MacBook speakers and AirPods) - 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
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the AVFoundation audio output path selected by --ao=avfoundation, focusing on the restart triggered by the system notification. Reproduce with the provided sample and --no-config, inspect mpvlog.txt, and compare device switching from macOS with switching inside mpv; done means switching outputs no longer causes the reported 30–40 dropped frames or desynchronisation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, macos
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100