visual studio 2015 Windows环境下编译 ffmpeg

一、代码下载

环境配置已经有人做好了,可以直接下载使用

  1. https://github.com/ShiftMediaProject/FFmpeg ,下载ffmpeg源码和vs的工程代码
  2. git clone项目后,在项目目录下有个SMP的目录,运行脚本project_get_dependencies.bat,会git clone ffmpeg所依赖的各个库,整个过程比较耗时,重复执行该命令,可以保证所有依赖代码全部下载。
  3. https://github.com/ShiftMediaProject/VSNASM/releases下载VSNASM。
  4. https://github.com/ShiftMediaProject/VSYASM/releases下载VSYASM

值得提示一下的是,从GitHub下载确实速度很慢,所以本人在gitee 从 github clone了一份 https://gitee.com/GuoYuLingJing

使用的时候把上面的 https://github.com/ShiftMediaProject 换成 https://gitee.com/GuoYuLingJing 即可(不包括Release发布的文件)

依赖库下载的具体操作:

  1. ffmpeg\SMP目录下复制一份 project_get_dependencies.bat 改名为 get_dep_gitee.bat
  2. 修改 get_dep_gitee.bat 里面 几个地方
SET UPSTREAMURL=https://gitee.com/GuoYuLingJing
SET DEPENDENCIES=( ^
bzip2, ^
fontconfig, ^
freetype2, ^
fribidi, ^
game-music-emu, ^
gnutls, ^
lame, ^
libass, ^
libbluray, ^
libcdio, ^
libcdio-paranoia, ^
libiconv, ^
libgcrypt, ^
libilbc, ^
liblzma, ^
libssh, ^
libxml2, ^
libvpx, ^
mfx_dispatch, ^
modplug, ^
opus, ^
sdl, ^
soxr, ^
speex, ^
theora, ^
vorbis, ^
x264, ^
x265, ^
xvid, ^
zlib, ^
gmp, ^
libgpg-error, ^
nettle, ^
harfbuzz, ^
ogg ^
)

更新变量 SET UPSTREAMURL=https://github.com/ShiftMediaProject

这个批处理命令在下载完依赖库后,还会检测被下载的依赖库是否还有其它依赖库,比如gnutls库就依赖nettle,gmp;所以本人直接在上面依赖库zlib后面直接把gmp, libgpg-error, nettle, harfbuzz, ogg 全部添加进去了。

在:cloneOrUpdateRepo末尾位置,把它判断是否还有依赖库的命令删除

IF EXIST "%REPONAME%\SMP\project_get_dependencies.bat" (
    ECHO %REPONAME%: Found additional dependencies...
    ECHO.
    cd %REPONAME%\SMP
    project_get_dependencies.bat "!PASSDEPENDENCIES!" || EXIT /B 1
    cd ..\..
)

如果使用了gitee url,另外还有一个主意的地方,就是 gnutls\gnulib 下面是没有任何文件的,因为原项目是引用更新自gitlab的

可以从这里下载: https://gitee.com/GuoYuLingJing/gnulib-mirror 或 https://gitlab.com/libidn/gnulib-mirror 

下载后复制文件夹 gnulib-mirror\lib 到 \gnutls\gnulib 目录下即可

二、编译环境配置

  1. 将下载的VSYASM和VSNASM中的.props,.targets和.xml文件复制到“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations”下。
  2. 从 http://yasm.tortall.net/Download.html 下载yasm(根据自己编译的ffmpeg位数而定),复制到“安装目录\Microsoft Visual Studio 14.0\VC\”下,并命名为yasm.exe。
  3. https://www.nasm.us/pub/nasm/releasebuilds/下载nasm(根据自己编译的ffmpeg位数而定),复制到“安装目录\Microsoft Visual Studio 14.0\VC\”下。
  4. 在ffmpeg/SMP下有一个说明文件readme.txt,需要额外配置opengl, ffnvcodec和AMF的include文件。

    1) opengl (requires glext)
        a) Download glext.h and wglext.h from opengl.org or https://github.com/KhronosGroup/OpenGL-Registry/tree/master/api/GL.
        b) Save the header files into "OutputDir/include/gl/*".
    2) ffnvcodec (requires nv-codec-headers)
        a) Download the nv-codec-headers repository from https://github.com/FFmpeg/nv-codec-headers or https://gitee.com/GuoYuLingJing/nv-codec-headers
        b) Save the contents of the nv-codec-headers repositories "include" folder into "OutputDir/include/*".
    3) AMF (requires Advanced Media Framework (AMF) SDK headers)
        a) Download the AMF repository from https://github.com/GPUOpen-LibrariesAndSDKs/AMF or https://gitee.com/GuoYuLingJing/AMF
        b) Save the contents of the AMF repositories "amf/public/include" into "OutputDir/include/AMF/*".

注意:上面的OutputDir是工程定义的宏 $(OutDir),本人这里看到的是 \..\..\..\msvc,即项目所在目录的上3级目录。

下载完上面的文件后,保存到相应的路径下,应该是下面的文件结构:

msvc\include\AMF
msvc\include\gl
msvc\include\ffnvcodec

笔者打包了这3样头文件,点击下载

三、编译

用VS2015打开ffmpeg/SMP下的ffmepg_deps.sln.编译整个工程即可,编译出的文件就在msvc目录下。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章