ffmpeg-2.1 最新修改的一部分函数
来源:互联网 发布:linux上安装telnet 编辑:程序博客网 时间:2024/06/03 09:06
ffmpeg源码包里面有个apichangs文档,里面有各种接口改变的记录,如果你发现接口不能用了,可以去搜索那个文档,可以找到对应的新接口,然后到新接口对应的头文件中找到说明文字
网上很多关于ffmpeg (libav)的资料都是N年以前的,而事实上ffmpeg数年来一直在“以时俱进”,因此无论是一些新手,或者号称为老手的人,有时候难免出头痛。。。。。。
为了解决大家的头痛的问题,特列一个贴子,把ffmpeg相关的一些常见的、版本的问题列举出来,供大家参考,同时也请大家一起补充。
1) 不认识guess_format.
解决: #define guess_format av_guess_format
接口不变。
2) 不认识av_alloc_format_context
解决: #define av_alloc_format_context avformat_alloc_output_context
接口调整。
3) 不认识CODEC_TYPE_VIDEO 和 CODEC_TYPE_AUDIO
解决:
#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
4) 不认识audio_resample_init
解决:#define audio_resample_init av_audio_resample_init
接口调整。
5) avcodec_decode_video 到 avcodec_decode_video2接口调整
旧代码:
- len = avcodec_decode_video(c, (short *)outbuf, &out_size, inbuf_ptr, size);
- av_init_packet(&pkt);
- pkt.data = (unsigned char*)inbuf_ptr;
- pkt.size = size;
- len = avcodec_decode_video2(c, &tmpFrame, &got_picture, &pkt);
av_open_input_file
/opt/workspace/android/EasyPlayer/jni/EasyPlayer/EasyPlayer.cpp:483: warning: 'int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)' is deprecated (declared at /opt/workspace/android/EasyPlayer/jni/EasyPlayer/../include/libavformat/avformat.h:1480)
新接口:复制代码av_find_stream_info
/opt/workspace/android/EasyPlayer/jni/EasyPlayer/EasyPlayer.cpp:494: warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /opt/workspace/android/EasyPlayer/jni/EasyPlayer/../include/libavformat/avformat.h:1526)
新接口:复制代码av_close_input_file
/opt/workspace/android/EasyPlayer/jni/EasyPlayer/EasyPlayer.cpp:522: warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /opt/workspace/android/EasyPlayer/jni/EasyPlayer/../include/libavformat/avformat.h:1706)
新接口:复制代码注意,这个是个2级指针。
avcodec_open2
新出来的avcodec_open2接口支持一些编解码特性的指定。
#ifdef __FFMPEG_0_6__
if (avcodec_open(ffmpeg_video.codec_ctx, ffmpeg_video.codec) < 0)
#else
if (avcodec_open2(ffmpeg_video.codec_ctx, ffmpeg_video.codec, NULL) < 0)
#endif
/opt/workspace/android/EasyPlayer/jni/EasyPlayer/EasyPlayer.cpp:483: warning: 'int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)' is deprecated (declared at /opt/workspace/android/EasyPlayer/jni/EasyPlayer/../include/libavformat/avformat.h:1480)
新接口:
- #ifdef _FFMPEG_0_6__
- if(av_open_input_file(&ffmpeg_fields.pFormatCtx, _filePath, NULL, 0, NULL) != 0)
- #else
- if (avformat_open_input(&ffmpeg_fields.pFormatCtx, _filePath, NULL, NULL) != 0)
- #endif
/opt/workspace/android/EasyPlayer/jni/EasyPlayer/EasyPlayer.cpp:494: warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /opt/workspace/android/EasyPlayer/jni/EasyPlayer/../include/libavformat/avformat.h:1526)
新接口:
- #ifdef _FFMPEG_0_6__
- if(av_find_stream_info(ffmpeg_fields.pFormatCtx) < 0)
- #else
- if (avformat_find_stream_info(ffmpeg_fields.pFormatCtx, NULL) < 0)
- #endif
/opt/workspace/android/EasyPlayer/jni/EasyPlayer/EasyPlayer.cpp:522: warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /opt/workspace/android/EasyPlayer/jni/EasyPlayer/../include/libavformat/avformat.h:1706)
新接口:
- #ifdef _FFMPEG_0_6__
- av_close_input_file(ffmpeg_fields.pFormatCtx);
- #else
- avformat_close_input(&ffmpeg_fields.pFormatCtx);
- #endif
avcodec_open2
新出来的avcodec_open2接口支持一些编解码特性的指定。
#ifdef __FFMPEG_0_6__
if (avcodec_open(ffmpeg_video.codec_ctx, ffmpeg_video.codec) < 0)
#else
if (avcodec_open2(ffmpeg_video.codec_ctx, ffmpeg_video.codec, NULL) < 0)
#endif
avcodec_init
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:20: warning: 'void avcodec_init()' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavcodec/avcodec.h:3932)
这个function已经不再需要了,当你调用avcodec_register()或者 avcodec_register_all()时,ffmpeg会自动调用它。所以放心大胆的移除掉就可以了。
url_fclose url_fopen url_fseek等等
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:67: warning: 'int url_fclose(AVIOContext*)' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavformat/avio.h:324)
这一系统的接口都只需要在前面加一个avio_的前缀就可以了,如:avio_close()。
avcodec_alloc_context()
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:111: warning: 'AVCodecContext* avcodec_alloc_context()' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavcodec/avcodec.h:4025)
使用最新接口:avcodec_alloc_context3()复制代码av_get_bits_per_sample_format
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:143: warning: 'int av_get_bits_per_sample_format(AVSampleFormat)' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavcodec/avcodec.h:4529)
新接口改为av_get_bytes_per_sample(反正音频bits per sample是8的倍数,不是8就是16,直接用byte比用bit更好)
audio_resample_init
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:157: error: 'audio_resample_init' was not declared in this scope
新接口:av_audio_resample_init,原先我以为ffmpeg要支持超过2 channels的resample,后来一看resample.c里的实现,结果发现还是只能支持mono和stereo
多出来的几个参数,给填default值:复制代码详见resample.c,或者参考RTSPPlayer中的easyffmpeg.cpp.
PKT_FLAG_KEY
没什么好说的,直接在前面加个AV_的前缀:AV_PKT_FLAG_KEY
av_alloc_format_context
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:722: error: 'av_alloc_format_context' was not declared in this scope
这个前面两位同仁有提到不同,但不说怎么个不同法,实在可恨,我直接写个例子:复制代码
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:20: warning: 'void avcodec_init()' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavcodec/avcodec.h:3932)
这个function已经不再需要了,当你调用avcodec_register()或者 avcodec_register_all()时,ffmpeg会自动调用它。所以放心大胆的移除掉就可以了。
url_fclose url_fopen url_fseek等等
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:67: warning: 'int url_fclose(AVIOContext*)' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavformat/avio.h:324)
这一系统的接口都只需要在前面加一个avio_的前缀就可以了,如:avio_close()。
avcodec_alloc_context()
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:111: warning: 'AVCodecContext* avcodec_alloc_context()' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavcodec/avcodec.h:4025)
使用最新接口:avcodec_alloc_context3()
- m_pACodec = avcodec_find_encoder((CodecID)nCodecID);
- if(!m_pACodec) return false;
- m_pAContext = avcodec_alloc_context3(m_pACodec);
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:143: warning: 'int av_get_bits_per_sample_format(AVSampleFormat)' is deprecated (declared at /opt/workspace/android/EasyIPCam/jni/libeasycodec/../3rdparty/libavcodec/avcodec.h:4529)
新接口改为av_get_bytes_per_sample(反正音频bits per sample是8的倍数,不是8就是16,直接用byte比用bit更好)
audio_resample_init
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:157: error: 'audio_resample_init' was not declared in this scope
新接口:av_audio_resample_init,原先我以为ffmpeg要支持超过2 channels的resample,后来一看resample.c里的实现,结果发现还是只能支持mono和stereo
多出来的几个参数,给填default值:
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_S16,
- TAPS, 10, 0, 0.8
PKT_FLAG_KEY
没什么好说的,直接在前面加个AV_的前缀:AV_PKT_FLAG_KEY
av_alloc_format_context
/opt/workspace/android/EasyIPCam/jni/libeasycodec/EasyCodec.cpp:722: error: 'av_alloc_format_context' was not declared in this scope
这个前面两位同仁有提到不同,但不说怎么个不同法,实在可恨,我直接写个例子:
- avformat_alloc_output_context2(&m_pFormatCtx, pOutputFmt, "avi", pFileName);
转自:http://blog.csdn.net/lptsun/article/details/8111348
0 0
- ffmpeg-2.1 最新修改的一部分函数
- Python_修改文件名的一部分
- 有关顺序表的一部分函数
- 我的ffmpeg SDK完成了:ffmpeg最新…
- sql 语句操作,修改字段中字符串的一部分
- 属性“waitingInvoiceAmount”是对象的一部分,不能被修改
- setjmp和longjmp的使用(个人修改其中一部分)
- FFmpeg的avcodec_decode_video2()函数
- 内置函数一部分
- Oracle8 的OCI常用函数及一部分参数说明
- 请编写一个函数,删除一个字符串的一部分。
- 请编写函数,删除一个字符串的一部分。
- jQuery JS 获取时间函数集 取时间的一部分
- 编写一个函数,删除一个字符串的一部分
- vlc-2.1.0的第三方库contrib的修改之ffmpeg的库的修改
- 最新FFMPEG解码流程
- 如何在Android移植使用最新的ffmpeg
- 最新 ffmpeg-ffplay for windows的编译-2012-5-10
- Appium手机自动化测试[转]
- Effective C++ 6.继承与面向对象设计
- onsubmit阻止form表单提交与onclick的相关操作
- 字符串重新排序,数字字符移到右边,字母字符移到左边,保持字符在原字符串中的前后顺序不变
- 网络营销培训的那点事,揭秘网络营销培训行业骗规则
- ffmpeg-2.1 最新修改的一部分函数
- Tomcat中的docBase配置(映射非webapps目录下的项目)
- 程序的内存分配
- 2013年个人微博推荐技术资料汇总
- Object-C 的构造函数析构函数
- ZOJ-1814
- mysql不能在更新一个表的同时查询同样的一张表
- SAP关于单位换算
- Leetcode: Add Two Numbers