ffmpeg 在VC2010 中的环境搭建

来源:互联网 发布:java常用算法手册豆瓣 编辑:程序博客网 时间:2024/06/05 20:51

最近开始研究ffmpeg。万事开头难,大家可能都希望能够运行sample code在VC2010吧。

这里list了方法,简而言之,分为如下几步:

1)http://ffmpeg.zeranoe.com/builds/ 

下载share版和dev版。我下的是64bit。 所以相应VC2010 project的建立也用x64版。

如果想用32bit版就下载相应的同时VC2010建立相应的project。

2)建立VC2010 空project后。copy dev版中的include文件夹下的所有文件夹到project中。同时copy dev版中的lib到project中。

3)像OpenCV一样,在project的property中,Linker->General->Additional Library Directories 填入lib的路径

在Linker->Input->Additional Dependencies 中填入 .lib结尾的文件

4) copy share版中的dll文件到project中

5) 由于VC不支持C99,所以我们还需拷贝2个文件去替换VC的原始文件。下载inttypes.h stdint.h, 替换C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include 下同名文件。

https://code.google.com/p/ffmpeg-wrapper/source/browse/trunk/ffmpeg_build/win32/include/?r=13

6) 在main.c 文件中

extern "C"  
{
#ifndef __STDC_CONSTANT_MACROS
#  define __STDC_CONSTANT_MACROS
#endif
#include "libavutil/imgutils.h"
#include "libavutil/parseutils.h"
#include "libswscale/swscale.h" 

.................

..............

};

这是一位作者写的文章,亲测,发现有几个小的问题,在这里做一下补充。
1我下的是32位的版本
第3步,应该补充一下 在project的property中,C/C++ ->常规->附件包含目录中,把你的.h文件的路径包含进去,这里是include。


第5步,网址打不开,参见下面的解决方案

包含libavutil\common.h,由于里面#include <inttypes.h> ,会出现找不到inttypes.h的问题,

即使把inttypes.h的路径加上去之后,也无法编译通过,反而会出现一大堆问题。

解决办法如下:

删除#include <inttypes.h>这句,加上下面一大段

//Howard 2013-03-04 , 解决包含inttypes.h以后出现的Bug
//#include <inttypes.h>
//Howard 2013-03-04 +++begin+++
#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 */


//解决UINT64_C没定义的问题
#ifndef INT64_C
#define INT64_C(c)(c##LL)
#define UINT64_C(c)  (c##ULL)
#endif 
0 0