Opened 19 months ago
Last modified 19 months ago
#10321 new enhancement
mov_channel_layout[] table possible issues
Reported by: | Tim | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Note: this is kind of a "thinking out loud" thing, possibly worth discussing anyway.
Example:
https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/a3f4916:/libavformat/isom.c#l400
{ AV_CH_LAYOUT_7POINT1, (128<<16) | 8}, // kCAFChannelLayoutTag_MPEG_7_1_C
kCAFChannelLayoutTag_MPEG_7_1_C = (128<<16) | 8, // L R C LFE Ls Rs Rls Rrs
Thus:
L | R | C | LFE | BL | BR | SL | SR AV_CH_LAYOUT_7POINT1 L | R | C | LFE | Ls | Rs | Rls | Rrs kCAFChannelLayoutTag_MPEG_7_1_C
BL == Ls (kCAFChannelLabel_LeftSurround)
BR == Rs (kCAFChannelLabel_RightSurround)
but SL (kCAFChannelLabel_LeftSurroundDirect) != Rls (kCAFChannelLabel_RearSurroundLeft)
and SR (kCAFChannelLabel_RightSurroundDirect) != Rls (kCAFChannelLabel_RearSurroundRight)
…also, perhaps importantly, as far as I can understand, SL and SR are supposedly closer to
the front channels than BL/Ls and BR/Rs whereas Rls Rrs are behind BL/Ls and BL/Rs, making
the mapping rather problematic?
On the other hand:
L | R | C | LFE | BL | BR | FLC | FRC AV_CH_LAYOUT_7POINT1_WIDE_BACK L | R | C | LFE | Ls | Rs | Lc | Rc kCAFChannelLayoutTag_MPEG_7_1_A
but there is no mapping for it in the mov_channel_layout table.
L | R | C | LFE | SL | SR | FLC | FRC AV_CH_LAYOUT_7POINT1_WIDE L | R | C | LFE | Ls | Rs | Lc | Rc kCAFChannelLayoutTag_MPEG_7_1_A
exists with SL == Ls and SR == Rs, which is also used by AV_CH_LAYOUT_5POINT1 ==
kCAFChannelLayoutTag_MPEG_5_1_A and several other mappings, but is somewhat less
problematic since there are no back channels in the corresponding AV_CH_LAYOUTs.
Also:
L | R | C | LFE | BL | BR | BC AV_CH_LAYOUT_6POINT1_BACK L | R | C | LFE | Ls | Rs | Cs kCAFChannelLayoutTag_MPEG_6_1_A
seems suitable but is absent from the table.
This would not work, on the other hand:
L | R | C | LFE | BC | SL | SR AV_CH_LAYOUT_6POINT1 L | R | C | LFE | Ls | Rs | Cs kCAFChannelLayoutTag_MPEG_6_1_A
(but does not exist in the table, just noteworthy)
Finally/FWIW https://developer.apple.com/documentation/coreaudiotypes/1572101-audio_channel_layout_tags?language=objc
Does list some additional WAVE-specific layout tags which are not
present in the CAF Channel Layout Chunk specification, for example:
kAudioChannelLayoutTag_WAVE_7_1 = (189U<<16) | 8
Change History (2)
comment:1 by , 19 months ago
comment:2 by , 19 months ago
Also, when using -c:a copy for e.g. ac3 input and CAF output, a chan will be written with the incorrect tag (corresponding to Libav's native channel order, not the ac3 bitstream's actual order)…
Here's some experiments re: "WAVE" layout tags in CAF (have not tested AIFF/MOV).
ffmpeg -i 7point1.dts -c:a pcm_s24le -f caf ffmpeg.caf
Using afconvert to force a change of channel layout tag w/out
re-ordering (instead, overriding the layout tag for the input):
Result:
Making kAudioChannelLayoutTag_WAVE_7_1 potentially useful.
However, the WAVE layout tags were not present several years ago, so I am unsure what is
the oldest version of macOS/afconvert that can actually read files with such tags "correctly".
afconvert -v -f caff -d LEI24 -l WAVE_6_1 -l WAVE_6_1 6.1.ffmpeg.caf 6.1.afconvert.caf
Other WAVE layout tags:
The _B layout tags are a bit redundant and can arguably only map to the _BACK channel layouts,
whereas the _A variants are a bit more versatile; the difference being Ls vs. Rls and Rs vs. Rrs:
afconvert -v -f caff -d LEI24 -l WAVE_5_1_B -l WAVE_5_1_B 5.1.ffmpeg.caf 5.1.afconvert.caf
afconvert -v -f caff -d LEI24 -l WAVE_5_1_A -l WAVE_5_1_A 5.1.ffmpeg.caf 5.1.afconvert.caf