FFMpeg中的实例output_example.c的编译
关于
ffmpeg
在
windows
上的编译,在
www.ffmpeg.com.cn
上有详细的讲解,在成功编译好
ffmpeg
后,便在
MSVC
中编译
ffmpeg
自带的实例
output_example.c
。
首先自己在
MSVC
下建立一个空的控制台的应用程序,将
output_example.c
加入到工程中。由于在
MSVC
中是使用编译
ffmpeg
时生产的
.lib
和
.dll
文件,所以我们需要连接它们。在这里我们需要
avcodec-51.lib
、
avformat-51.lib
和
avutil-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>” 然后保存:
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
#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)。
<script src="http://s.vdoing.com/u/107/54977.js" type="text/javascript"></script>