How to compile FFMPEG for Windows 11

How to compile FFMPEG for Windows 11

Compiling FFMPEG on Windows 11 may seem daunting, but it’s actually quite simple if you follow the proper steps. Here’s how:

Prerequisites

Download and install Microsoft Visual Studio 2022. You can download the latest version of Visual Studio from the Microsoft website.

Download and install MSYS2: https://www.msys2.org/

Once the installation is complete, an MSYS2 console will be opened. Install the following prerequisites in this console:

pacman -S make
pacman -S yasm
pacman -S diffutils
pacman -S pkg-config
pacman -S git

Compile

Open a Windows terminal, then run:
(the path might change according to visual studio version)

"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
C:\msys64\msys2_shell.cmd -full-path

An MSYS terminal will be opened. In this new console:

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg_x64
cd ffmpeg_x64
make clean
./configure --target-os=win64 --arch=x86_64 --toolchain=msvc --disable-everything --enable-shared --enable-decoders --enable-protocols --enable-demuxers --enable-hwaccels --enable-parsers --enable-bsfs --enable-indevs --enable-outdevs --enable-filters
make
make install

The FFmpeg output will be located in C:\msys64\home\<user>\ffmpeg_x64

This is the compilation of FFMPEG with basic functions. For advanced compilation with x264 support, follow this article: x264 and FFMPEG compilation for Windows