一、FFmpeg编译
1、配置msys2环境
- 在 msys2官网中下载msys2-x86_64-{date}.exe安装
- 修改msys64/msys2_shell.cmd文件中rem MSYS2_PATH_TYPE=inherit为set MSYS2_PATH_TYPE=inherit,记得备份
- 打开vs x64命令行提示符工具,运行msys2_shell.cmd,输入以下命令初始化环境
pacman -Syu
pacman -S make
pacman -S diffutils
pacman -S yasm
pacman -S nasm
mv /usr/bin/link.exe /usr/bin/link.exe.bak
2、编译x264源码
- (注意提前进入某个目录创建一个FFmpeg_Build目录,源码解压在同级目录下)
- https://github.com/mirror/x264拉下来
- msys64进入x264目录,执行命令:
curl "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" > config.guess
sed -i 's/host_os = mingw/host_os = msys/' configure
CC=cl ./configure --prefix=./../FFmpeg_Build --enable-shared
make -j 16 && make install
mv ./../FFmpeg_Build/lib/libx264.dll.lib ./../FFmpeg_Build/lib/libx264.lib
3、编译FFmpeg源码
export CC=cl
./configure \
--prefix=./../FFmpeg_Build \
--toolchain=msvc \
--arch=x86_64 \
--enable-yasm \
--enable-asm \
--enable-shared \
--disable-static \
--disable-programs \
--enable-avresample \
--enable-libx264 \
--enable-gpl \
--extra-ldflags="-LIBPATH:./../FFmpeg_Build/lib/" \
--extra-cflags="-I./../FFmpeg_Build/include/"