Compile FFmpeg with fdk-aac on Windows
This guide provides a step-by-step walkthrough for compiling a custom
FFmpeg binary with the high-quality Fraunhofer FDK AAC library
(libfdk-aac) on Windows. Due to licensing conflicts between
the GPL and the non-free FDK AAC license, pre-compiled public binaries
containing both cannot be legally distributed. By using the MSYS2 build
environment, you can compile and link these components directly on your
machine.
Step 1: Install MSYS2
Download the MSYS2 installer from the official site and install it on your system (recommended path:
C:\msys2).Once installed, open the MSYS2 MinGW 64-bit terminal (do not use the standard MSYS terminal).
Update the package database and core packages:
pacman -SyuIf prompted to close the terminal, close it, reopen MSYS2 MinGW 64-bit, and run the command again until everything is up to date.
Step 2: Install Build Dependencies
Run the following command in the MSYS2 MinGW 64-bit terminal to install the necessary compilers, build tools, and utilities:
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-nasm gitPress Enter to select all default packages when
prompted.
Step 3: Clone and Compile fdk-aac
Clone the
fdk-aacsource code:git clone https://github.com/mstorsjo/fdk-aac.git cd fdk-aacConfigure and install the library as a static build:
autoreconf -fiv ./configure --prefix=/mingw64 --disable-shared --enable-static make -j$(nproc) make install cd ..
Step 4: Clone and Configure FFmpeg
Clone the latest FFmpeg source repository:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg cd ffmpegConfigure FFmpeg with
--enable-libfdk-aacand the mandatory--enable-nonfreeflag:./configure \ --prefix=/mingw64 \ --enable-gpl \ --enable-nonfree \ --enable-libfdk-aac \ --disable-shared \ --enable-static \ --pkg-config-flags="--static"
Step 5: Compile FFmpeg
Compile the binary using all available CPU cores:
make -j$(nproc)
make installThe compilation process can take several minutes depending on your system's hardware.
Step 6: Verify the Installation
Check if the newly built
ffmpeg.exeis working:ffmpeg -versionThe output should show
--enable-libfdk-aacand--enable-nonfreein the configuration banner.Verify that the
libfdk_aacencoder is available:ffmpeg -encoders | grep libfdk_aac
The compiled ffmpeg.exe file will be located in your
MSYS2 directory under C:\msys2\mingw64\bin\ffmpeg.exe. You
can copy this executable to any directory on Windows or add
C:\msys2\mingw64\bin to your Windows system
PATH environment variable.