一、代碼下載
環境配置已經有人做好了,可以直接下載使用
- 到 https://github.com/ShiftMediaProject/FFmpeg ,下載ffmpeg源碼和vs的工程代碼
- git clone項目後,在項目目錄下有個SMP的目錄,運行腳本project_get_dependencies.bat,會git clone ffmpeg所依賴的各個庫,整個過程比較耗時,重複執行該命令,可以保證所有依賴代碼全部下載。
- 從https://github.com/ShiftMediaProject/VSNASM/releases下載VSNASM。
- 從https://github.com/ShiftMediaProject/VSYASM/releases下載VSYASM
值得提示一下的是,從GitHub下載確實速度很慢,所以本人在gitee 從 github clone了一份 https://gitee.com/GuoYuLingJing
使用的時候把上面的 https://github.com/ShiftMediaProject 換成 https://gitee.com/GuoYuLingJing 即可(不包括Release發佈的文件)
依賴庫下載的具體操作:
- ffmpeg\SMP目錄下複製一份 project_get_dependencies.bat 改名爲 get_dep_gitee.bat
- 修改 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 目錄下即可
二、編譯環境配置
- 將下載的VSYASM和VSNASM中的.props,.targets和.xml文件複製到“C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations”下。
- 從 http://yasm.tortall.net/Download.html 下載yasm(根據自己編譯的ffmpeg位數而定),複製到“安裝目錄\Microsoft Visual Studio 14.0\VC\”下,並命名爲yasm.exe。
- 從https://www.nasm.us/pub/nasm/releasebuilds/下載nasm(根據自己編譯的ffmpeg位數而定),複製到“安裝目錄\Microsoft Visual Studio 14.0\VC\”下。
- 在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目錄下。