ffmpeg重采样中swr_convert和swr_get_out_samples的用法
来源:互联网 发布:淘宝店铺取什么名字好 编辑:程序博客网 时间:2024/06/07 03:39
ffmpeg重采样中swr_convert和swr_get_out_samples的用法
在做mux的时候关于重采样可以用fifo,或者audiofifo做缓存处理,当做demux的时候关于重采样就可以用到上面的swr_convert和swr_get_out_samples做配合处理。先看下这两个函数的注释:
/** 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 using swr_get_out_samples() to retrieve an * upper bound on the required number of output samples for the given number of * input samples. Conversion will run directly without copying whenever possible. * * @param s allocated Swr context, with parameters set * @param out output buffers, only the first one need be set in case of packed audio * @param out_count amount of space available for output in samples per channel * @param in input buffers, only the first one need to be set in case of packed audio * @param in_count number of input samples available in one channel * * @return number of samples output per channel, negative value on error */int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count);
/** * Find an upper bound on the number of samples that the next swr_convert * call will output, if called with in_samples of input samples. This * depends on the internal state, and anything changing the internal state * (like further swr_convert() calls) will may change the number of samples * swr_get_out_samples() returns for the same number of input samples. * * @param in_samples number of input samples. * @note any call to swr_inject_silence(), swr_convert(), swr_next_pts() * or swr_set_compensation() invalidates this limit * @note it is recommended to pass the correct available buffer size * to all functions like swr_convert() even if swr_get_out_samples() * indicates that less would be used. * @returns an upper bound on the number of samples that the next swr_convert * will output or a negative value to indicate an error */int swr_get_out_samples(struct SwrContext *s, int in_samples);
没有缓存的重采样这么处理:
ret = swr_convert(swrcontext, pOutputFrame->data,pOutputFrame->nb_samples,(const uint8_t**)pInputFrame->data,pInputFrame->nb_samples);
有缓存的代码这么处理:
//如果还有缓存在swrcontext中,第二个参数要填写0才能获取到,缓存数据int fifo_size = swr_get_out_samples(swrcontext,0);if ( fifo_size >= pOutputFrame->nb_samples){ret = swr_convert(swrcontext, pOutputFrame->data,pOutputFrame->nb_samples,NULL,0);}
即如果有缓存则先判断是否有缓存在里面,如果有则传入数据为空取出缓存。
如有错误请指正:
交流请加QQ群:62054820
QQ:379969650.
0 0
- ffmpeg重采样中swr_convert和swr_get_out_samples的用法
- FFmpeg swr_convert 音频重采样,编码的噪音问题
- swr_convert音频重采样成AV_SAMPLE_FMT_FLTP
- ffmpeg音频转码,采用swr_convert重取样
- ffmpeg音频转码,采用swr_convert重取样
- ffmpeg音频转码,采用swr_convert重取样
- [FFMPEG-2]最想实现的第一点一个功能-从mp3中提取pcm数据,重采样和加wav头
- ffmpeg音频重采样分析
- ffmpeg解复用解码重采样
- 金字塔和重采样的解析
- ffmpeg实现音频resample(重采样)
- ffmpeg实现音频resample(重采样)(二)
- ffmpeg实现音频resample(重采样)
- ffmpeg 利用AVFilter音频重采样
- 【FFmpeg(2016)】SwrContext重采样结构体
- 解决ffmpeg 重采样中的bug。
- ffmpeg实现音频resample(重采样)
- ffmpeg重采样resample包含AVAudioFifo(三)
- mui 开发知识积累-------打开页面的方式
- ndk环境搭建(HelloJNI开发)
- MAC笔记本 Safari,Chrome等浏览器无法打开网页
- tensorflow-000-Overview
- file_get_contents的post请求
- ffmpeg重采样中swr_convert和swr_get_out_samples的用法
- steam vr 简单开发
- git的使用以及遇到的小坑
- Android个人学习笔记-底部导航切换Fragment的实现
- php表单加入Token防止重复提交的方法分析
- The WSDL document http://localhost:8080/xxxx/xxx.wsdl could not be read
- 算法竞赛入门经典-第五章字母重排
- PHP连接到MYSQL数据库的相关操作
- LAMP 搭建