[FFmpeg-trac] #7384(avcodec:reopened): FFmpeg 4.0 does not set 5.1 surround sound into audio stream when converting mkv video with 5.1 surround sound
FFmpeg
trac at avcodec.org
Thu Jun 3 17:08:36 EEST 2021
#7384: FFmpeg 4.0 does not set 5.1 surround sound into audio stream when
converting mkv video with 5.1 surround sound
-------------------------------------+-------------------------------------
Reporter: itrdev | Owner: (none)
Type: defect | Status: reopened
Priority: important | Component: avcodec
Version: git-master | Resolution:
Keywords: aac | Blocked By:
regression |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by YetAnotherID):
I've only just bumped into this issue, and found quite a few closed
tickets on the subject, but as this ticket is active recently I thought
I'd add my 2 cents worth here.
Sorry if I'm getting any of this wrong, but I can't imagine how it's not
the problem.
I've always understood that for AAC using a centre channel, the golden
rule is to make the first element a single channel element, and to end
with a single channel element, if it exists. I think the LFE channel is a
specially labelled SCE.
In other words, the channel order begins with the centre channel, then the
stereo channels are encoded in pairs from front to back, and the final SCE
is the back centre channel (if it exists). Whether the surround channels
are "back" or "side" in wave file channel order shouldn't matter. They're
encoded as surround channels. If there's only a pair of them it's 5.1ch
audio, if there's two pairs it's 7.1ch.
Best as I can tell, ffmpeg is storing the AAC elements in wave file
channel order, rather then the AAC order of FC, FL, FR, Ls, Rs, LFE.
https://wiki.multimedia.cx/index.php/MPEG-4_Audio#Channel_Configurations
For AAC there's "num_front_channel_elements" for specifying the number of
front speakers, but the specification seems fairly determined about the
order of the elements.
https://web.archive.org/web/20110713115817/http://jongyeob.com/moniwiki/pds/upload/13818-7.pdf
'''8.5.1 Data Elements'''
'''num_front_channel_elements'''
''The number of audio syntactic elements in the front channels, front
center to back center, symmetrically by left and right, or alternating by
left and right in the case of single channel elements (Table 25).''
This is the other info I dug out of an AAC stream with MediaInfo, so in
the order they appear to be stored (ffmpeg encoded).
channel_configuration: 0 (0x0) - (4 bits) -
num_front_channel_elements: 2 (0x2) - (4 bits) - Front: FL FR FC
num_side_channel_elements: 1 (0x1) - (4 bits) - LFE becomes Side: C
num_back_channel_elements: 1 (0x1) - (4 bits) - Back: L R
num_lfe_channel_elements: 0 (0x0) - (2 bits)
The worst part is, I don't think you need to use a PCE for 5.1ch audio if
you follow the element order rules. Even if you don't, it'd probably be
assumed to be the front centre channel if there's only one SCE.
'''8.5.2.3 Implicit channel mapping'''
''1) Any number of SCE's may appear (as long as permitted by other
constraints, for example profile). If this number of SCE's is odd, then
the first SCE represents the front center channel, and the other SCE's
represent L/R pairs of channels, proceeding from center front outwards and
back to center rear.
If the number of SCE's is even, then the SCE's are assigned as pairs as
center-front L/R, in pairs proceeding out and back from center front
toward center back.''
Or you can use Channel_Configuration to specify a channel layout, and not
bother specifying the number of front or side channels etc, although from
what I can tell, it has to be used with the elements in the correct order.
That's all QAAC seems to do.
channel_configuration: 6 (0x6) - (4 bits) - Front: L C R, Side: L R, LFE
Unfortunately the implicit channel order for 7.1ch audio is the cinema
layout (where there's extra stereo channels in the front rather than extra
surround channels), and because ffmpeg has encoded 7.1ch as 7.1ch (front),
then decoded it as 7.1ch (wide), and QAAC began using PCE's for 7.1ch a
long time ago, I've not kept up with any changes to the way ffmpeg does
it, so I've no idea if it's using PCE's now, or doing so correctly, but it
seems to me this is something that it should be doing according to the
spec.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7384#comment:14>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list