[FFmpeg-user] Is swr_convert() able to resample the audio from 1 channel to 2 channels?

Paul B Mahol onemda at gmail.com
Tue Feb 19 16:59:42 CET 2013


On 2/19/13, JIA Pei <jp4work at gmail.com> wrote:
> Hi, all:
>
> Sorry for my naive questions. I'm trying to decode audio stream using
> avcodec_decode_audio4(). After I obtained the audio frame by
> avcodec_decode_audio4(), I'd love to resample audio signals using
> swr_convert() ----
>
> its definition is pasted as follows:
>
> int swr_convert(struct SwrContext *s, uint8_t **out, int out_count,
>
>                                 const uint8_t **in , int in_count);
>
>
>
> Now, my question:
> 1) is swr_convert() able to convert audio signals from 1 channel to 2
> channels ????

Yes, if you give rights args to swr_alloc_set_opts() prior to calling
swr_convert

> 2) for swr_convert(), if there are 2 audio channels (stereo audio signals),
> how is the data organized in unit8_t **out?
> Does out[0] only contain the left channel audio signals?
> Does out[1] contain the right channel audio signals?
> Why in my case, out[1] always points to NULL ?

It depends on sample format you set in swr_alloc_set_opts().

For planar sample formats out[x] have x channel

For interleaved sample formats there is out[0] only and it have
all channels interleaved: ABABABABAB -> stereo: A is 1st and B 2nd channel.

>
>
> Please do help... Thank you...
>
>
> Best Regards
>
> --
>
> Pei JIA
>
> Email: jp4work at gmail.com
> cell:    +1 604-362-5816
>
> Welcome to Vision Open
> http://www.visionopen.com
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list