FFMpeg中的实例output_example.c的编译

来源:互联网 发布:防弹少年团amas知乎 编辑:程序博客网 时间:2024/05/22 06:19

                 FFMpeg中的实例output_example.c的编译

关于ffmpegwindows上的编译,在www.ffmpeg.com.cn上有详细的讲解,在成功编译好ffmpeg后,便在MSVC中编译ffmpeg自带的实例output_example.c
首先自己在MSVC下建立一个空的控制台的应用程序,将output_example.c加入到工程中。由于在MSVC中是使用编译ffmpeg时生产的.lib.dll文件,所以我们需要连接它们。在这里我们需要avcodec-51.libavformat-51.libavutil-49.lib这三个静态库,故在我们编译工程之前就将它们加到工程中。
 
编译会发现提示: Cannot open include file: 'inttypes.h': No such file or directory 的出错信息,可通过如下方法解决:
1
、找到include目录中的ffmpeg/common.h
2
、在“#define COMMON_H”之后加入如下代码,同时删除“#include <inttypes.h>” 然后保存:
 
 再次编译出现错误
     error C2054: “inline”之后应输入“(”
 这样一系列错误,我们只要在“#define COMMON_H”之后加入如下代码
 #if defined(WIN32) && !defined(__cplusplus)
#define inline __inline
#endif
 再次编译发现出现error LNK2019: 无法解析的外部符号_snprintf,该符号在函数_main 中被引用
这个连接错误(注意要是没有将开头说的那三个库先加入,这儿出现的连接错误更多)。
 分析后知道错误是由第470行
 snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
 引起的,解决方案如下:
MSVC 2005:
 修改为_snprintf_s(oc->filename, _countof(oc->filename), 1024, "%s", filename);
 
MSVC 6.0
 修改为_snprintf(oc->filename, sizeof(oc->filename), "%s", filename)。