如何用vc顺利编译ffmpeg

From Ffmpeg工程组

Jump to: navigation, search

如何用vc顺利编译ffmpeg

这是编译问题,而不是技术问题
C语言熟练的话,在VC下修改完成编译问题不是很大。
最主要是把那些不符合规范的语句修改好。举两个例子:
1) c->time_base= (AVRational){1,25}; 修改为:
    c->time_base.num = 1;
   c->time_base.den = 25;
2)static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { ... } 里面
的写法也不对。
...
VC下编译根据各人的技术积累经验,难度不是很大,基本上
都是体力活。C很熟的人把全部修改过来两到三天足够了。

ffmpeg中除了包含c语言部分还有部分的汇编语言,所以ffmpeg在VC下顺利编译需要的外部编译器

  • 1.GCC
我很久以前编译该项目的时候所使用的工具。
GCC很好找,因为它是免费的工具。
GCC主要用来编译ffmpeg的汇编代码。
ffmpeg中的汇编代码使用GCC编译时的编译选项
gcc -c -O3 -march=i586 -mtune=i686 -fomit-frame-pointer -finline -finline-functions 
- DHAVE_AV_CONFIG_H -pipe -mno-cygwin -mdll -I. -I.. $(InputPath) -o $(IntDir)\$(InputName).obj
-Ilibavutil
  • 2.Intel C++
intel C++是intel开发的。它支持许多 C语言的国际标准,
ffmpeg项目中用的很多编码标准c99标准,而Intel C++支持这些标准。

但是全部编译是会遇到一些问题的

这里是ffmpeg文档里关于vc编译器的说明
FFmpeg will not compile under Visual C++ -- and it has too many dependencies on the GCC compiler 
to make a port viable. However, if you want to use the FFmpeg libraries in your own applications
, you can still compile those applications using Visual C++. An important restriction to this 
is that you have to use the dynamically linked versions of the FFmpeg libraries (i.e. the DLLs), 
and you have to make sure that Visual-C++-compatible import libraries are created during the 
FFmpeg build process.
意思就是说有些依赖gcc和汇编,vc下比较困难,但是没必要在vc下编译整个库,只需要在vc下编译工程文件,然后调用ffmpeg
的库就可以了。

例如:

ffdshow项目中的ffmpeg工程可以用vc编译通过,如果是vc6.0,需要手工改一些代码,vc2003或是vc2005都没有问题。

有关该问题的讨论帖可参考ffmpeg工程组论坛中的相关讨论:

有关如何用vc顺利编译ffmpeg的讨论
Personal tools