[Libav-user] avcodec_open2 is changing the channels and channel_layout... why?
Carl Eugen Hoyos
cehoyos at ag.or.at
Fri Oct 12 00:06:05 CEST 2012
Michael Bradshaw <mbradshaw at ...> writes:
> I've just been hunting down a bug in one of our programs, and I
> tracked it down to the number of channels reported by ffmpeg. When I
> first open the AVFormatContext and do avformat_find_stream_info(), I
> can see that my audio stream's AVCodecContext has a reported
> channel_layout of 3 (stereo) and channels == 2. However, when I call
> avcodec_open2() to start decoding, it changes the streams'
> AVCodecContext channel info so that channel_layout is 4 (mono) and
> channels == 1! This is causing a crash in a later part of the program,
> as one part of the program expects two channels and the other part
> expects 1 channel.
> Two questions:
> 1) Is this "expected behavior" in any case, or is it a bug?
While I cannot really answer the question, I wonder
what you expect when the number of channels really change:
At least for AC-3 and AAC, this is not only allowed,
but happens regularly (for example on DVB).
So perhaps your application should expect a change...
More information about the Libav-user