The Complete Guide to Compiling FFmpeg with All Features on Ubuntu

FFmpeg is the Swiss Army knife of multimedia processing. It can handle almost any audio or video task you can imagine: transcoding, remuxing, filtering, streaming, extracting metadata, generating thumbnails, normalizing audio, and much more.

Ubuntu’s repository packages are good enough for many users, but compiling FFmpeg from source gives you tighter control over codecs, filters, licensing choices, and build options. It is also useful when you need a newer FFmpeg release than the one packaged by your distribution.

This guide walks through compiling FFmpeg on Ubuntu with a broad set of commonly used features, plus fixes for several errors you may hit along the way.

Why Compile FFmpeg from Source?

Compiling FFmpeg yourself can be useful when you need:

  • A newer FFmpeg release than the one available through apt
  • Support for codecs or filters omitted from distribution builds
  • Control over GPL, version 3, and non-free components
  • Hardware-specific optimizations
  • A reproducible build configuration for servers or workstations

The tradeoff is maintenance. A source build will not be updated automatically by Ubuntu’s package manager, so you need to rebuild it when you want security fixes or newer features.

Prerequisites

This guide assumes:

  • Ubuntu 24.04 Noble Numbat, or a similar recent Ubuntu release
  • Basic terminal familiarity
  • sudo privileges
  • Enough disk space for source files, build artifacts, and dependencies

Before starting, check whether you already have FFmpeg installed:

ffmpeg -version
which ffmpeg

If Ubuntu’s packaged FFmpeg is installed and you later install a custom build under /usr/local, your shell may prefer /usr/local/bin/ffmpeg depending on your PATH order. Verify this after installation.

Step 1: Download FFmpeg Source Code

Create a source directory and download the FFmpeg release tarball:

mkdir -p ~/ffmpeg_sources
cd ~/ffmpeg_sources
wget https://ffmpeg.org/releases/ffmpeg-7.1.1.tar.bz2
tar xjf ffmpeg-7.1.1.tar.bz2
cd ffmpeg-7.1.1

If you want a different release, check the current versions at the official FFmpeg download page and adjust the filename accordingly.

Step 2: Install Build Dependencies

Install the compiler toolchain and development libraries:

sudo apt-get update
sudo apt-get install -y \
  autoconf \
  automake \
  build-essential \
  cmake \
  git \
  libass-dev \
  libfreetype-dev \
  libgnutls28-dev \
  libmp3lame-dev \
  libsdl2-dev \
  libtool \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  meson \
  ninja-build \
  pkg-config \
  texinfo \
  wget \
  yasm \
  nasm \
  zlib1g-dev \
  libx264-dev \
  libx265-dev \
  libnuma-dev \
  libvpx-dev \
  libfdk-aac-dev \
  libopus-dev \
  libdav1d-dev \
  libtheora-dev \
  libfribidi-dev \
  libharfbuzz-dev \
  libfontconfig1-dev \
  libpulse-dev \
  libsoxr-dev \
  libspeex-dev \
  libxml2-dev \
  libzvbi-dev \
  libbs2b-dev \
  libsnappy-dev \
  libgsm1-dev \
  libopencore-amrnb-dev \
  libopencore-amrwb-dev \
  libbluray-dev \
  libssh-dev \
  libssl-dev \
  libopenal-dev \
  librubberband-dev \
  libfftw3-dev \
  libopenmpt-dev

Package names can change between Ubuntu releases. If apt reports Unable to locate package, search for the current name:

apt search freetype dev
apt search libdc1394

Troubleshooting Package Issues

On Ubuntu 24.04 Noble, several package names differ from older guides:

  • libfreetype6-dev is now commonly installed as libfreetype-dev
  • git-core is now just git
  • libdc1394-22-dev is now commonly installed as libdc1394-dev

Some optional packages, such as libflite-dev, may not be available from the standard repositories. In that case, either omit the corresponding FFmpeg option, enable another repository that provides the package, or build that dependency from source.

Step 3: Configure FFmpeg

Run FFmpeg’s configure script with the features you want enabled:

./configure \
  --prefix=/usr/local \
  --enable-gpl \
  --enable-version3 \
  --enable-nonfree \
  --enable-shared \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-pthreads \
  --enable-libspeex \
  --enable-libsoxr \
  --enable-libxml2 \
  --enable-libbluray \
  --enable-libfontconfig \
  --enable-libfribidi \
  --enable-libharfbuzz \
  --enable-libpulse \
  --enable-gnutls

This configuration enables a wide range of audio, video, subtitle, font, and network-related features. It also enables --enable-nonfree because libfdk-aac requires it. A build configured with --enable-nonfree is not redistributable under FFmpeg’s normal licensing terms, so use it for your own systems rather than packaging it for others.

Common Configuration Errors and Solutions

1. Missing FreeType Headers

You may see:

fatal error: ft2build.h: No such file or directory
#include <ft2build.h>

Install the FreeType development package:

sudo apt-get install libfreetype-dev

Then rerun ./configure.

2. NASM/YASM Not Found

You may see:

nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.

Install NASM:

sudo apt-get install nasm

Then rerun ./configure. You can use --disable-x86asm, but that disables important assembly optimizations and is usually not the right fix.

3. LibASS Not Found

You may see:

ERROR: libass >= 0.11.0 not found using pkg-config

Install the LibASS development package:

sudo apt-get install libass-dev

Then confirm pkg-config can see it:

pkg-config --modversion libass

4. GnuTLS and OpenSSL Conflict

You may see:

GnuTLS and OpenSSL must not be enabled at the same time.

Choose one TLS backend. For example:

./configure --enable-gnutls

or:

./configure --enable-openssl

Do not enable both in the same FFmpeg build.

Step 4: Compile and Install FFmpeg

After configuration succeeds, compile FFmpeg:

make -j"$(nproc)"

This uses all available CPU cores. The build may take several minutes to half an hour depending on your hardware and selected features.

Install the compiled binaries and libraries:

sudo make install

Update the shared library cache:

sudo ldconfig

If your shell still finds the old FFmpeg binary, check the path order:

which ffmpeg
echo "$PATH"

You may need to open a new shell or adjust your PATH so /usr/local/bin is searched before /usr/bin.

Step 5: Verify the Installation

Check the installed FFmpeg version and configuration:

ffmpeg -version
ffmpeg -buildconf

Confirm the expected encoders, decoders, and filters are present:

ffmpeg -encoders
ffmpeg -decoders
ffmpeg -filters

For targeted checks, use grep. For example:

ffmpeg -encoders | grep -E 'libx264|libx265|libfdk_aac|libopus'
ffmpeg -filters | grep subtitles

A simple transcode test is also useful:

ffmpeg -f lavfi -i testsrc2=size=1280x720:rate=30 -f lavfi -i sine=frequency=1000:sample_rate=48000 -t 5 -c:v libx264 -c:a aac test-output.mp4
ffprobe test-output.mp4

Customizing Your Build

The configuration above is broad, but it is not the only sensible build. Add or remove options based on what you actually use.

For hardware acceleration, the exact options depend on your GPU, driver, and SDK installation. Common areas to investigate include:

  • VAAPI on Intel or AMD systems: --enable-vaapi
  • NVIDIA NVENC/NVDEC support: verify the current FFmpeg documentation and NVIDIA codec headers required by your FFmpeg release
  • CUDA-related workflows: verify the CUDA toolkit and FFmpeg options supported by your installed version

For additional formats and libraries, consider:

  • --enable-libopenmpt for tracker music formats
  • --enable-libgsm for GSM audio
  • --enable-librubberband for time stretching and pitch shifting
  • --enable-libsoxr for high-quality audio resampling

Before enabling an option, check that the corresponding development package is installed and visible to pkg-config:

pkg-config --list-all | grep -i soxr
pkg-config --modversion soxr

Consult the official FFmpeg Compilation Guide and the configure help for the most accurate options for your release:

./configure --help

Troubleshooting Tips

  1. Read the first real error, not just the final make failure line. The useful message is often earlier in the output.
  2. If a library is reported as missing, install its -dev package and confirm it appears in pkg-config.
  3. Check ffbuild/config.log after configure failures. It records the exact compiler and linker tests that failed.
  4. Keep licensing in mind. --enable-gpl, --enable-version3, and --enable-nonfree affect how the resulting binary may be distributed.
  5. If compilation runs out of disk space, clean temporary build files with make clean, or build in a directory with more space.
  6. If the installed binary cannot find shared libraries, run sudo ldconfig and inspect library paths with ldd "$(which ffmpeg)".

Conclusion

Compiling FFmpeg from source gives you maximum control over codecs, filters, licensing choices, and installation paths. It requires more effort than installing the Ubuntu package, but it is worthwhile when you need a specific feature set or a newer FFmpeg release.

After following this guide, verify your build with ffmpeg -version, ffmpeg -buildconf, and a small test transcode. Once those checks pass, your custom FFmpeg build is ready for real audio and video processing work.

Leave a Reply