[vlc-devel] Re: Transcode stereo stream to mono AMR

Jean-Paul Saman jean-paul.saman at planet.nl
Tue Feb 27 09:12:24 CET 2007

Herman Meerlo wrote:
> Herman Meerlo wrote:
>> Hi,
>> I am trying to transcode a public stereo stream to mobile format using 
>> the AMR audio codec (and H.263 for video). This gives no problem if 
>> the input source is mono because AMR is mono as well. But when the 
>> input source is stereo (or more) then the transcode fails.
>> The problem has been around for a long time and I was wondering 
>> whether there is a workaround for this? Can someone maybe explain what 
>> is going wrong so I can try to make a patch mysel. I would think that 
>> it can not be very hard to transcode the input to mono. Or am I 
>> missing something?
> Because nobody seems to be able to help, I dove into the code myself. I 
> have read lots of the code and had many debug session to try to 
> understand how VLC internally works. I do not pretend to know the 
> internals now because that is impossible for such a complex project. But 
> my analysis had led me to believe there is a fundamental design problem 
> with running audio_filters while transcoding a stream (please correct me 
> if I am wrong!).
> I ran into this problem while trying to use the mono plugin to change 
> the number of channels from 2 to 1 for the AMR codec. The problem lies 
> in the fact that the plugin requires knowledge on the physical channels 
> (i_physical_channels) during initialization of the plugin. But the 
> filter is initialized before any input sample has been decoded. 
> Therefore the channel configuration is not known yet. This causes the 
> mono filter to think that there are 0 channels, which will cause it to 
> divide by 0 => FPE (mono.c line 495)
> So while transcoding a stream the entire chain is setup before anything 
> is known about the channel configurations which makes it impossible to 
> apply any audio filter. It will probably only work if the output of the 
> decoder and the input of the encoder have the same number of channels.
> Can anyone comment on this?
That is a correct observation. Mind the mono stream out audio filter can 
only output DUAL mono (2 channels) to ffmpeg. The mono audio is send 
over 2 channels left and right.

Jean-Paul Saman.

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html

More information about the vlc-devel mailing list