it's actually really easy. The reason why I spent such a big thing is that I tried to compile on the WIN7 virtual machine, so there are various inexplicable errors.
Reference: https://www.jianshu.com/p/5f175dec9109 .
- Environmental preparation
WIN10,VS2015。
- Download FFmpegInterop
https://github.com/microsoft/FFmpegInterop
- Download ffmpeg
Download, decompress, rename ffmpeg, and place it under FFmpegInterop.
- Download and install MSYS2
Download x86_64; install in c: \ msys64
- Configuration
c:\msys64\usr\bin目录下,把link.exe改名为link.bak,这样可以调用VS的link。
Edit C: \ msys64 \ msys2_shell.cmd:
rem set MSYS2_PATH_TYPE=inherit
改成
set MSYS2_PATH_TYPE=inherit
Edit C: \ msys64 \ home \ XXXX \ .bashrc
export PATH=/C/'Program Files (x86)'/'Microsoft Visual Studio 14.0'/VC/bin/amd64:${PATH}
- Start MSYS2
set MSYS2_BIN="C:\msys64\usr\bin\bash.exe"
cd c:\msys64
msys2_shell.cmd -mingw64
Right click, options, text, Character set changed to UTF-8.
- MSYS2 installation software
For reference, the MinGW-w64 method is recommended.
pacman -S mingw-w64-x86_64-toolchain
pacman -S nasm
# pacman -S make gcc diffutils pkg-config
- Check compilation commands
$ which cl
/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl
$ which link
/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link
$ which yasm
/usr/bin/yasm
$ which cpp
/mingw64/bin/cpp
- Compile x264
Download, unzip, and compile.
./configure \
--prefix=../lib-ffmpeg \
--host=x86_64-w64-mingw32 \
--enable-shared --extra-ldflags=-Wl,--output-def=libx264.def
make
make install
Convert to dll
#若要生成64位lib文件则输入如下命令:
lib /machine:X64 /def:libx264.def
#若要生成32位lib文件则输入如下命令:
lib /machine:i386 /def:libx264.def
- configure
Modify FFmpegConfig.sh
--enable-gpl \
--enable-nonfree \
--enable-libx264 \
--extra-cflags="-I${BUILD_LIBS}/include" \
--extra-ldflags="-LIBPATH:${BUILD_LIBS}/lib"
carried out:
./FFmpegConfig.sh Win10 x64
Said to open the newly generated config.h file and convert it to UTF-8 format. This avoids many warnings.
- make
./BuildFFmpeg.bat win10 x64
- Check 32-bit or 64-bit:
查看32位还是64位:
dumpbin /headers libx264.dll
查看符号清单(导出函数)
dumpbin /exports libx264.dll > libx264-exports.txt