安装msys2,直接https://www.msys2.org/上下载exe安装即可,默认路径;
选择msys2-mingw64启动,将下载源替换为中科大
sed -i "s#mirror.msys2.org/#mirrors.ustc.edu.cn/msys2/#g" /etc/pacman.d/mirrorlist*pacman -Sy
pacman -S mingw-w64-x86_64-toolchain # mingw64编译工具链,win下的gccpacman -S base-devel # 一些基本的编译工具pacman -S yasm nasm # 汇编器pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-cmake-gui #安装cmake,编译x265需要pacman -S mingw-w64-x86_64-SDL2 # 支持ffplay需要
# git clone https://code.videolan.org/videolan/x264.git# git clone https://bitbucket.org/multicoreware/x265_git.git
这里我将下载的源码都存放在D盘ffmpeg文件夹下面,以及后面要安装的路径install也在这里,方便管理。
# 在msys2-mingw64终端里cd /d/ffmpeg/x264 #这里我将源码都放在D盘ffmpeg文件夹下面./configure --prefix=/d/ffmpeg/install/usr --enable-sharedmake -j4 && make install
-DCMAKE_INSTALL_PREFIX
#!/bin/sh# Run this from within an MSYS bash shellcmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=/d/ffmpeg/install/usr ../../source && cmake-gui ../../source
cmake-gui默认配置即可,然后configure、generate
make && make install
cd /d/ffmpeg/ffmpeg-6.0.1PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/d/ffmpeg/install/usr/lib/pkgconfig ./configure --prefix=/d/ffmpeg/install/usr --enable-gpl --enable-ffplay --enable-shared --disable-stripping --disable-static --extra-cflags=-I/d/ffmpeg/install/usr/include --extra-ldflags=-L/d/ffmpeg/install/usr/lib# 根据有无libx264和libx265可选选项:--enable-libx264 --enable-libx265 make -j4 && make install
编译完的ffmpeg在/d/ffmpeg/install/usr/bin下面,可以看到ffmpeg支持dxva2和d3d11va以及vulkan等video硬件加速。