mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.76k stars 2.86k forks source link

Mac OS X Core Audio Layout problem #3065

Open mpsrig opened 8 years ago

mpsrig commented 8 years ago

Hello,

The handling of Core Audio layouts has a problem.

On multichannel systems there are 2 layouts, the "stereo" layout and the "multichannel" layout. The stereo layout is handled in an interesting way - it is "parsed" into an mpv layout the same way as the multichannel layout.

This should not be the case. Rather, mpv should simply assume that the stereo layout is in fact stereo, and send left and right audio to those channels.

Another option (at least on my system) would be for mpv to recognize that the layout "na-na-na-na-na-na-na-na-na-na-fl-fr" is stereo 2 channel on channels 11 and 12 and act accordingly. It doesnt seem to know how to handle nonstandard patching.

Attached is an example of this on my system. Left and Right are channels 11 and 12 on the audio interface, so mpv "parses" stereo as "sr-tc", has no idea what to do with this, and falls back to mono.

I realize that this may also be a symptom of a small bug in OS X but we can definitely work around this.

[ao] Trying audio driver 'coreaudio'
[ao/coreaudio] requested format: 48000 Hz, stereo channels, floatp
[ao/coreaudio] selected audio output device: Scarlett 8i6 USB (38)
[ao/coreaudio] input channel layout:
[ao/coreaudio] layout: tag: <0>, bitmap: <0>, descriptions <12>
[ao/coreaudio]  - description 0: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 1: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 2: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 3: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 4: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 5: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 6: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 7: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 8: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 9: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 10: label <1, 0>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 11: label <2, 1>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio] mp chmap: na-na-na-na-na-na-na-na-na-na-fl-fr
[ao/coreaudio] input channel layout:
[ao/coreaudio] layout: tag: <0>, bitmap: <0>, descriptions <2>
[ao/coreaudio]  - description 0: label <11, 10>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 1: label <12, 11>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio] mp chmap: sr-tc
[ao/coreaudio] Channel layouts:
[ao/coreaudio]  - na-na-na-na-na-na-na-na-na-na-fl-fr
[ao/coreaudio]  - sr-tc
[ao/coreaudio]  - mono
[ao/coreaudio] result: mono
[ao/coreaudio] Latency property cntl: 48 frames
[ao/coreaudio] Latency property zisf: 512 frames
[ao/coreaudio] Latency property tfas: 49 frames
[ao/coreaudio] audiounit latency [us]: 0
[ao/coreaudio] device latency [us]: 12687
[ao/coreaudio] using soft-buffer of 9600 samples.
ghost commented 8 years ago

Yeah, we could just remove the code that reads and applies the stereo layout, and assume stereo is always supported.

But what's the point of the stereo layout at all?

ghost commented 8 years ago

CC @pigoz

pigoz commented 8 years ago

@mpsrig can you post a screenshot of how your speaker layout is configured in Audio MIDI Setup.app? This looks like misconfiguration on your end? (or bad drivers / osx integration of your DAC)

mpsrig commented 8 years ago

The point of stereo layout is to route stereo audio. This can be separate from multichannel audio. I.E. unless the app is sending surround sound, it should simply send stereo or mono audio to the system using the "stereo" path. MPV does this fine but only in the mono case, not the stereo case. Screenshots to follow.

mpsrig commented 8 years ago

screenshot 2016-04-19 11 51 11

mpsrig commented 8 years ago

screenshot 2016-04-19 11 51 16

pigoz commented 8 years ago

Your config looks indeed correct, this looks like a bug in mpv.

mpsrig commented 8 years ago

In every other app this works. All audio is stereo and is routed to 11 as left and 12 as right. This is not a bug on my system.

mpsrig commented 8 years ago

Ideally what should happen is that unless the app is sending multichannel audio i.e. 5.1 or 7.1, it should drop to the stereo path. I.E. I should be able to have surround set up on 5.1 on interface channels 1-6 and stereo set up on 11-12 and it should work fine. This works great in VLC. Shouldn't be too hard a fix.

mpsrig commented 8 years ago

Update: It seems that MPV has trouble with pretty much any nonstandard audio layout. I changed my setup to be 5.1 on standard channels 1-6 and it still gets thrown off by channels 7-12 being "na" and outputs either mono (when the "stereo" output setup in Audio MIDI setup is set to 11 and 12) or stereo (when the "stereo" output is set to 1 and 2). The input file is 5.1 and VLC does this fine.

ghost commented 8 years ago

Please post logs with -v for all interesting cases.

mpsrig commented 8 years ago

case1-stereo_is11and12-multichannel_is_stereo11and12.txt case2-standard-stereo1and2-multichannel_5.1-1thru6.txt case3-stereo11and12-multichannel_5.1-1thru6.txt

Happy to post more on request, though it seems that it doesn't know what to do with my 12ch audio interface no matter how it's set up except to output stereo to channels 1 and 2 or mono to whatever the system default for stereo is.

ghost commented 8 years ago

And you never actually want 5.1 output? (Since a while ago we've switched back to stereo/mono downmix output by default.)

mpsrig commented 8 years ago

No, in the case where multichannel out is set to 5.1 on channels 1-6 I would expect it to do 5.1 output from a 5.1 source mkv - I guess I will have to look into the command line flags for this?

Michael Stella

Sent from my phone - please forgive errors.

On Apr 19, 2016, at 3:05 PM, V. Lang notifications@github.com wrote:

And you never actually want 5.1 output? (Since a while ago we've switched back to stereo/mono downmix output by default.)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

ghost commented 8 years ago

Yes, you need to set --audio-channels=auto in this case.

mpsrig commented 8 years ago

Thanks for the tip. There is obviously still a bug here though. Will update.

hmedia1 commented 5 years ago

Having a similar issue - added findings to #5042

pixlwave commented 5 years ago

I think I'm seeing the same issue. When playing a video with a stereo audio track, the output is falling back to mono. Relevant section of the log:

[ad] Codec list:
[ad]     aac - AAC (Advanced Audio Coding)
[ad]     aac_fixed (aac) - AAC (Advanced Audio Coding)
[ad]     aac_at (aac) - aac (AudioToolbox)
[ad] Opening decoder aac
[ad] Requesting 1 threads for decoding.
[ad] Selected codec: aac (AAC (Advanced Audio Coding))
[af] User filter list:
[af]   (empty)
[cplayer] Starting playback...
[af] [in] 48000Hz stereo 2ch floatp
[af] [userspeed] 48000Hz stereo 2ch floatp
[af] [userspeed] (disabled)
[af] [convert] 48000Hz stereo 2ch floatp
[ao] Trying audio driver 'coreaudio'
[ao/coreaudio] requested format: 48000 Hz, stereo channels, floatp
[ao/coreaudio] selected audio output device: MicroBook IIc (59)
[ao/coreaudio] input channel layout:
[ao/coreaudio] layout: tag: <0>, bitmap: <0>, descriptions <8>
[ao/coreaudio]  - description 0: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 1: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 2: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 3: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 4: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 5: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 6: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 7: label <4294967295, 64>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio] mp chmap: unknown8
[ao/coreaudio] input channel layout:
[ao/coreaudio] layout: tag: <0>, bitmap: <0>, descriptions <2>
[ao/coreaudio]  - description 0: label <3, 2>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio]  - description 1: label <4, 3>,  flags: <0>, coords: <0.000000, 0.000000, 0.000000>
[ao/coreaudio] mp chmap: fc-lfe
[ao/coreaudio] Channel layouts:
[ao/coreaudio]  - fc-lfe
[ao/coreaudio]  - mono
[ao/coreaudio] result: mono
[ao/coreaudio] Latency property cntl: 45 frames
[ao/coreaudio] Latency property zisf: 512 frames
[ao/coreaudio] Latency property tfas: 46 frames
[ao/coreaudio] audiounit latency [us]: 354
[ao/coreaudio] device latency [us]: 12562
[ao/coreaudio] using soft-buffer of 9600 samples.
[cplayer] AO: [coreaudio] 48000Hz mono 1ch floatp
[cplayer] AO: Description: CoreAudio AudioUnit
[autoconvert] inserting resampler
[swresample] format change, reinitializing resampler
[swresample] 48000Hz stereo floatp -> 48000Hz mono floatp
[swresample] Remix: stereo -> mono
[af] [out] 48000Hz mono 1ch floatp

Audio Midi config is as follows (note that "Main 1" is actually channel 3 and "Main 2" is actually channel 4): screenshot 2019-01-19 at 22 27 27

hmedia1 commented 5 years ago

And you never actually want 5.1 output? (Since a while ago we've switched back to stereo/mono downmix output by default.)

Hi, what you're referring to here - the default downmix - where is this implemented ? I am wondering if it plays a part in #5042