Audio channels (L-R) swapped

Open
#18,802 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, macos

Research direction

Start by reading the CoreAudio output code and the history of PR #15622 and PR #18679, which changed handling of kAudioOutputUnitProperty_ChannelMap. Compare the current behavior with the attached log and reproduce using the stated stereo test and Audio MIDI Setup channel swap on macOS. Done means mpv's CoreAudio output reflects that channel map without breaking initialization.

Written by the indexing model from the issue text.

Description

os:mac
mpv Information
mpv v0.42.0 Copyright © 2000-2026 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.387.0
FFmpeg version: 9.0.2
FFmpeg library versions:
   libavcodec      63.1.102
   libavdevice     63.1.102
   libavfilter     12.1.102
   libavformat     63.1.102
   libavutil       61.1.102
   libswresample   7.1.102
   libswscale      10.1.102
Other Information
- macOS version: macOS 27.2 (26B123)
- Source of mpv: Homebrew
- Latest known working version: 0.41.0, sort of, further discussion below
- Issue started after the following happened: Audio MIDI Setup used to reverse channels
Reproduction Steps
Image
  • Play the video with mpv and note that the left and right channels are not swapped

When reproducing the problem I ran mpv with these options:

low-batt@gag ~$ mpv --no-config --gpu-debug --log-file=output.txt ~/Movies/Stereo\ Test\ -\ Left⧸Right\ Audio\ Test\ for\ Headphones⧸Speakers\ \[YwNs1Z0qRY0\].mp4 
● Video  --vid=1  --vlang=eng  (h264 1920x1080 30 fps 384 kbps) [default]
● Audio  --aid=1  --alang=eng  (aac 2ch 48000 Hz 128 kbps) [default]
AO: [coreaudio] 48000Hz fr-fl (stereo) 2ch floatp
VO: [gpu-next] 1920x1080 yuv420p
Audio device underrun detected.          
AV: 00:00:20 / 00:00:20 (100%) A-V:  0.000 Dropped: 4
Exiting... (End of file)
low-batt@gag ~$ 
Expected Behavior

The mpv audio channel layout reflects the changes made using the Audio MIDI Setup app.

Actual Behavior

The channel layout does not reflect the configuration applied by Audio MIDI Setup.

This is sort of a reopening of closed issue #15584. I say "sort of" because the situation is now different.

The title of #15584 indicates the problem is with the coreaudio driver:

Audio channels (L-R) swapped using coreaudio, avfoundation correct

Also in #15584 I reported this:

Play the above video with QuickTime Player and VLC and note the left and right channels are reversed as expected

And this:

Running mpv with --ao=avfoundation the behavior is as expected and matches QuickTime Player and VLC.

That was under macOS 15. Much of this behavior has changed. This is the behavior I'm now experiencing under macOS 27 with the speakers swapped:

App Left Speaker Right Speaker
ffplay 9.0.2 Left Channel Right Channel
QuickTime 10.5 (1278.2) Left Channel Right Channel
mpv 0.39.0 avfoundation Left Channel Right Channel
mpv 0.42.0 coreaudio Left Channel Right Channel
mpv 0.42.0 avfoundation Left Channel Right Channel
VLC 3.0.24 Right Channel Left Channel

Now only VLC properly reflects the configuration applied in Audio MIDI Setup.

Issue #15584 was "fixed" by PR #15622. With the changes in that PR, mpv exhibited the correct behavior and reflected the configuration applied in Audio MIDI Setup. However the wrong type of value was being assigned to the kAudioOutputUnitProperty_ChannelMap property. Apparently the incorrect value just happened to provide the correct behavior. That was up until macOS 27 where Apple added validation that detected the wrong type of value was being assigned and rejected it causing coreaudio initialization to fail (issue #18384). Setting the wrong type of value has been fixed by PR #18679, without addressing the problem described in this issue.

Log File

output.txt

Sample Files

I downloaded the YouTube video Left/Right Audio Test for Headphones/Speakers like so:

yt-dlp -f 137+140 https://www.youtube.com/watch?v=YwNs1Z0qRY0
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.
Dominant language
C
Stars
38.2k
Forks
3.7k
Avg merge
1d 13h
Merged PRs (30d)
76

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mpv-player/mpv

All issues in mpv-player/mpv

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.