mingw下vs编译的ffmpeg如何支持x264


上篇文章完成了 mingw下使用vs2015编译器编译FFMPEG(http://blog.csdn.net/anbinger2013/article/details/49387377),那么如何进一步 支持x264的。显然直接使用mingw下用gcc生成的静态库(libx264.a)文件是不妥的,会导致很多linker错误,提示许多未定义的函数。而且gcc产生的静态库兼容性不好,经常出现莫名其妙的运行死机错误。

另一种思路是在mingw下用vs来编译x264,但是x264的工具链没有ffmpeg的完善,不知道如何实现,网上的资料也比较少。 


此处的方案是使用mingw下gcc生成的DLL来实现对X264的支持。

步骤如何:

1.参考 ffmpeg官网 http://ffmpeg.org/platform.html

    make sure any other headers and libs you want to use, such as zlib, are located in a spot that the compiler can see. Do so by modifying the LIB and INCLUDE environment variables to include the Windows-style paths to these directories. Alternatively, you can try and use the --extra-cflags/--extra-ldflags

   意思是在WIN7的我的电脑里创建LIB和INCLUDE变量或者使用mingw的--extra-cflags和--extra-ldfags,我没有使用第一种方法,总觉得添加这样的全局环境变量不合适,第二种方法试了,但是总是提示找不到 x264库。所以本人直接修改 msys.bat文件,在call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"语句下面加上:

  set INCLUDE=d:\mingw\msys\1.0\local\include;%INCLUDE%

 set LIB=d:\mingw\msys\1.0\local\lib;%LIB%

2.下载x264源代码,使用mingw gcc编译生成动态库并make install

3. 参考  mingw 下编译的libx264 DLL 如何在vs2010里使用 (http://blog.csdn.net/anbinger2013/article/details/48998289), 制作x264.lib并放到D:\MinGW\msys\1.0\local\lib

4.进入ffmpeg源代码目录, ./configure --enable-libx264 --enable-encoder=aac --enable-static --enable-nonfree --enable-memalign-hack --enable-gpl --enable-version3 --toolchain=msvc 

然后make -j12, make install


至此,mingw下vs编译的ffmpeg就完成了对x264的支持微笑。可以在vs2015里调用了,引用的lib如下:

#pragma comment(lib,"libavcodec.a")
#pragma comment(lib,"libavformat.a")
#pragma comment(lib,"libavutil.a")
#pragma comment(lib,"libswscale.a")
#pragma comment(lib,"libswresample.a")
#pragma comment(lib,"libpostproc.a")
#pragma comment(lib,"libavfilter.a")
#pragma comment(lib,"libavdevice.a")
#pragma comment(lib,"x264.lib")
#pragma comment( lib, "wsock32.lib")  
#pragma comment( lib, "ws2_32.lib") 



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值