Build FFMpeg on windows - bryanch/random GitHub Wiki
References
Prerequisites
- Setup MSYS2 environment (refer to this wiki)
Clone the source
git clone git://source.ffmpeg.org/ffmpeg
Alternative options
- mirror on github:
https://github.com/FFmpeg/FFmpeg.git
- Microsoft interop project at https://github.com/microsoft/FFmpegInterop
git clone --recursive git://github.com/microsoft/FFmpegInterop.git
Install packages
normal msys2 packages
pacman -S make pkg-config diffutils
mingw-w64 packages and toolchains
pacman -S mingw-w64-x86_64-nasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2
Build using MINGW-W64
configure, this step may take quite some minutes
./configure
build, as said in the official instructions, use make -r to speed up the time for re-building
make -r
Build using MSVC
Refer to the the official instructions, the configure
step needs an extra parameter
./configure --toolchain=msvc
Build with GPU acceleration support
Reference the official instructions
- Download and install the CUDA toolkit
- Install Microsoft Visual Studio VC tools
- Open a VC Command Prompt (e.g. "x64 Native Tools Command Prompt for VS 2019"), add two paths
set INCLUDE=%INCLUDE%;%CUDA_PATH%\include set LIB=%LIB%;%CUDA_PATH%\lib\x64
- Open MSYS shell by executing the msys_shell.bat
- Clone and enable ffnvcodec header
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git cd nv-codec-headers make make install PREFIX=/usr
- configure including CUDA headers
cd ~/ffmpeg ./configure --toolchain=msvc --arch=x86_64 --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp
- make
make -j 10