How to Compile FFmpeg with FDK-AAC on Windows

This guide provides a straightforward, step-by-step walkthrough for compiling FFmpeg with the high-quality Fraunhofer FDK AAC (libfdk_aac) library on Windows. Because of licensing conflicts between the GPL and the FDK AAC license, pre-compiled binaries containing both are not legally distributable, making a custom local build necessary. By using the MSYS2 environment, you can safely and quickly compile your own custom FFmpeg executable with FDK AAC support enabled.

Step 1: Install MSYS2

MSYS2 provides a Unix-like environment and the package management system needed to compile FFmpeg on Windows.

  1. Download and run the MSYS2 installer from the official MSYS2 website.
  2. Install it to the default directory (usually C:\msys64).
  3. Once installed, search your Windows Start Menu for MSYS2 MinGW 64-bit and open it. Do not use the default MSYS terminal; the MinGW 64-bit terminal is required for building 64-bit Windows binaries.

Step 2: Update the Environment and Install Build Tools

In the MSYS2 MinGW 64-bit terminal, run the following command to update the package database and core system packages:

pacman -Syu

If the terminal closes during this update, reopen the MSYS2 MinGW 64-bit terminal and run the command again.

Next, install the required compiler toolchain, build utilities, and git:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain git make nasm yasm pkg-config

When prompted to select packages, press Enter to install all default selections.

Step 3: Install the FDK-AAC Library

You can install the pre-compiled static library of FDK AAC directly through the MSYS2 package manager, which simplifies the process:

pacman -S mingw-w64-x86_64-fdk-aac

Step 4: Download the FFmpeg Source Code

Clone the official FFmpeg git repository and navigate into the directory:

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg

Step 5: Configure and Compile FFmpeg

To compile FFmpeg with FDK-AAC, you must configure the build with the --enable-gpl, --enable-nonfree, and --enable-libfdk-aac flags.

  1. Run the configuration script:
./configure --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-static --disable-shared
  1. Once the configuration completes without errors, start the compilation process. Use the -j flag followed by the number of CPU cores you want to allocate to speed up the compile time (for example, -j4 for 4 cores):
make -j$(nproc)

The compilation process may take several minutes depending on your computer’s performance.

Step 6: Verify the Installation

After the compilation finishes successfully, you can verify that your custom FFmpeg binary has been created with FDK AAC support. Run:

./ffmpeg.exe -version

Look at the output under configuration. You should see --enable-libfdk-aac listed among the build flags.

The compiled ffmpeg.exe file will be located inside your ffmpeg directory. You can copy this executable to any directory on your computer and add it to your Windows System PATH to run it from any command prompt.