Join GitHub today
Multichannel LPCM always downmixed to stereo on HDMI 7.1-capable device #3319
mpv git-ad2d10a built Feb 29 03:20:47
Play media file with multichannel non-bitstreamable audio such as LPCM-5.1
Pass unchanged audio with original channel map to output
ALSA reports HDMI device as stereo causing mpv to remix audio to 2.0
Extract below along with config files
Another ALSA headache, judging by the code comments in alsa.c. I'm hoping to have a single command-line call to mpv that will work for any media file with any audio, bitstreamable formats to be bitstreamed over HDMI to the AVR, all other formats to be passed/converted to multichannel LPCM over HDMI to the AVR.
System: Home Theatre PC - Asus Z87 board and Intel Ivybridge i3 CPU using onboard graphics/audio - no addon cards at all. The PC is connected via HDMI to an AV Receiver with 5.1 speakers, no other devices apart from the TV - a very simple system.
Bitstreaming works fine. I determined the correct device from the MPV audio-devices list and put it in the config file, along with the audio-spdif parameter. Media files with ac3, truehd, dts and dts-hd are bitstreamed over HDMI to the AVR that correctly identifies the format on its panel.
However despite trying numerous permutations of settings in various config files (such as .asoundrc), multichannel audio, e.g. LPCM-5.1, is always downmixed to 2.0. The verbose output confirms that ALSA is reporting the channel map as stereo FL FR, causing MPV to do a Remix, despite the alsacap utility reporting the capability as 2..8 channel:-
[ad] Codec list:
*** Scanning for playback devices ***
mpv config file (the last 2 lines are probably redundant but I tried them anyway - makes no difference):-
mpv audio-device list:-
List of detected audio devices:
aplay -l output:-
**** List of PLAYBACK Hardware Devices ****
I tried ignore-chmap in the mpv config file and thought it had worked when alsa reported a multichannel map, but:-
The channel map reported by alsa is FL FR RL RR FC LFE, which corresponds to the audio-channels parameter "5.1(alsa)". This results in audio going to the wrong speakers.
It's a Catch 22 now: I've tried specifing the correct channel map in audio-channels, both as "5.1" and an explicit channel layout, but in both cases of course ignore-chmap tells alsa to ignore it.
Research ongoing - if you can think of a good way out, let me know.
A quick report on (lack of) progress on the original problem, it might help other people setting up an HTPC/AVR system.
I've adopted the more robust approach of separating bitstreamable formats from others and specifying a different audio device for each, which means an extra argument to the function and having two calls of mpv. Referring to my audio-devices file posted above, the arrangement that works in all cases is (in pseudo-code):
function play (mediafile, bitstreamable)
Inelegant, but it works well and is easier to manage if something changes system-wise.
mpv --audio-channels=help lists three variations of 5.1:- "5.1", "5.1(alsa)" and "5.1(side)".
I had the same problem (openSUSE TW w/Pulse installed). It started failing sometime in the last few months (had been working fine for a couple of years):
I then added the ignore-chmap option and set channels to 5.1(alsa) and now it works. When I tried pulse, the channels were clearly not mapped properly for my AVR and there was no sound.
Also interesting is that my audio player (JRiver MediaCenter) has handled alsa multichannel just fine.
From this and other research, I've concluded that having multichannel LPCM in an MKV file is a very bad idea, the channel layout is unreliable. Some combination of the method used to produce the media file, the operating system, the software player and hardware will conspire to cause layout problems in some cases.