opus: Multichannel audio not correctly reordered
When we try to encode and then decode a 7.1 multichannel audio stream with opus the order of the decoded channels is not the original one.
The issue can be reproduced on both Windows and Linux by comparing the audio reproduced on a 7.1 audio device using the subsequent pipelines and this sample wav file: https://www2.iis.fraunhofer.de/AAC/7.1auditionOutLeader%20v2.wav
gst-launch-1.0 -vv -m filesrc location=sample_7_1.wav ! decodebin ! audioconvert ! autoaudiosink
gst-launch-1.0 -vv -m filesrc location=sample_7_1.wav ! decodebin ! audioconvert ! opusenc bitrate=128000 ! queue ! opusdec ! audioconvert ! autoaudiosink
When opusenc + opusdec are used the source channels are played in this order:
- Front-Left: OK
- Front-Right: OK
- Front-Central -> Sise-Left Speaker
- LFE -> Side-Right Speaker
- Rear-Left -> Front-Central Speaker
- Rear-Right -> Subwoofer
- Side-Left -> Rear-Left Speaker
- Side-Right -> Rear-Right Speaker
According the encoder's caps the 8 channel mapping is <0, 6, 1, 4, 5, 2, 3, 7>
which corresponds to map the
{FL, FR, RL, RR, SL, SR, FC, LFE}
encoded channels to the vorbis order {FL, FC, FR, SL, SR, RL, RR, LFE}
.
The issue seem not raised with 6 channels
However during some tests we were able to play the channels in the correct speakers by using the <0, 4, 1, 2, 3, 6, 7, 5>
mapping.
Our suspect is that opusenc is encoding the channels in an unexpected order like {FL, FR, SL, SR, FC, LFE, RL, RR}
.