[FFmpeg-devel] Channel layouts (was: [PATCH] lavfi: store and propagate number of channels information in audio buffer properties)

Carl Eugen Hoyos cehoyos at ag.or.at
Sun Nov 11 23:24:05 CET 2012

Nicolas George <nicolas.george <at> normalesup.org> writes:

> Le primidi 21 brumaire, an CCXXI, Michael Niedermayer a écrit :
> > nicolas, stefano, ubitux any comments ?
> I take this opportunity to mention the test you recently added to
> lavfi/avcodec to check that channel count and layout are consistent.
> I may have given you the impression that this test was wrong, 
> but I do not believe it is. Well, just a little bit: the 
> problem is not "libavfilter does not support", the problem is 
> "the channel layout is bogus".
> My point is that whenever both a channel count and a channel 
> layout are present, they MUST be consistent.

But the current problem imo is that ffmpeg invents a layout 
if it is unknown and even if it unsupported (making it 
impossible for the user / caller to understand what is 
going wrong), see tickets #1763, #1764.

> Obviously, they are not at the output of the truehd 
> decoder, and this should be fixed. It also should be detected
> much earlier. Probably directly in avcodec_decode_audio4:
>     if (ret >= 0 && *got_frame_ptr) {
> 	av_assert1(!frame->channel_layout ||
> 	           frame->channels == 
> av_get_channel_layout_nb_channels(frame->channel_layout));
>     }

(I can't comment on the TrueHD issue, but files can 
obviously have different channel counts and 
incorrectly written layouts, and looking at ticket 
#1819, I wonder if it may be perfectly valid for 
some isom files to show stereo for mono files.)

> You also mention files that contain extended layouts 
> that can not be expressed with the bit mask of the 
> channel_layout field. Well, we knew that a bit mask 
> was a very limited data structure; it was enough for 
> some time, but if this kind of codec start to appear, 
> it is no longer, and we should start thinking about 
> what to use instead.

I'd like to point out that afaik we have no sample 
that cannot be correctly described by wav-channel 
layout, we just have bugs.
Those should be fixed imo, if you can point to samples 
that need extra work, we can still consider it.
As said before, the sample from ticket #98 can be 
perfectly represented, it just has to be reordered.
(And the original mov layout should be preserved 
for remuxing.)

Carl Eugen

More information about the ffmpeg-devel mailing list