swr_convert函数介绍

来源:互联网 发布:p2p h.264网络摄像机 编辑:程序博客网 时间:2024/05/22 19:32

由于ffmpeg最新版本(从2.1开始貌似)使用avcodec_decode_audio4函数来解码音频,但解码得到的数据类型为float 4bit,而播放器播放的格式一般为S16(signed 16bit),就需要对解码得到的数据进行转换,然而,ffmpeg已经帮我们做好了,只需调用API就可以了,这个函数就是:swr_convert

以下为从ffmpeg官网的复制:


原型:int swr_convert(struct SwrContext * s,  uint8_t ** out,   int out_count,  const uint8_t ** in,  int in_count )

Convert audio.

in and in_count can be set to 0 to flush the last few samples out at the end.

If more input is provided than output space then the input will be buffered. You can avoid this buffering by providing more output space than input. 

Convertion will run directly without copying whenever possible.

Parameters
sallocated Swr context, with parameters setoutoutput buffers, only the first one need be set in case of packed audioout_countamount of space available for output in samples per channelininput buffers, only the first one need to be set in case of packed audioin_countnumber of input samples available in one channel
Returns
number of samples output per channel, negative value on error
用时注意,第一个参数初始化后还需要将解码环境中的一部分参数赋给它。

1 0
原创粉丝点击