您的位置:首页 > 编程语言 > PHP开发

FFMpeg中的实例output_example.c的编译

2008-01-18 21:25 295 查看
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>” 然后保存:
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
#    define CONFIG_WIN32
#endif
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(EMULATE_INTTYPES)
#    define EMULATE_INTTYPES
#endif
#ifndef EMULATE_INTTYPES
#   include <inttypes.h>
#else
typedef signed char  int8_t;
typedef signed short int16_t;
typedef signed int   int32_t;
typedef unsigned char  uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int   uint32_t;
#   ifdef CONFIG_WIN32
typedef signed __int64   int64_t;
typedef unsigned __int64 uint64_t;
#   else /* other OS */
typedef signed long long   int64_t;
typedef unsigned long long uint64_t;
#   endif /* other OS */
#endif /* EMULATE_INTTYPES */

再次编译出现错误
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)。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: