32blogby StudioMitsu
Archive7 min read

Building a Redistributable FFmpeg on Linux

How to build a legally redistributable FFmpeg binary on Linux (Ubuntu, CentOS, Arch). Covers LGPL configure options, excluding patented codecs, packaging, and CI/CD automation.

The FFmpeg packages available through apt, yum, and pacman are convenient for personal use, but they often include codecs covered by patents and licenses that may restrict redistribution. If you're shipping FFmpeg as part of a commercial product or embedding it in software you distribute, you need a build you control.

This guide covers building FFmpeg on Linux with a configuration suitable for redistribution — excluding patented and GPL-only codecs, building as a shared library for LGPL compliance, and packaging the result.

What you'll learn

  • Setting up a build environment on Ubuntu, CentOS, and Arch Linux
  • Configuring FFmpeg for LGPL-compliant redistribution
  • Excluding patent-encumbered codecs while keeping useful ones
  • Building, installing, and verifying the result
  • Packaging options: tar.gz, .deb, .rpm
  • Automating with GitHub Actions and Docker

Build Environment Setup

Supported environments

This guide targets:

  • OS: Ubuntu 22.04 LTS / Debian 12 / CentOS 8 / Arch Linux
  • Architecture: x86_64 or ARM (Raspberry Pi, etc.)
  • Permissions: A user with sudo access

Install build dependencies

Ubuntu / Debian:

bash
sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential yasm nasm pkg-config \
    libtool autoconf automake cmake git

CentOS / RHEL:

bash
sudo yum groupinstall -y "Development Tools"
sudo yum install -y yasm nasm pkgconfig libtool autoconf automake cmake git

Arch Linux:

bash
sudo pacman -Syu --needed base-devel yasm nasm pkg-config \
    libtool autoconf automake cmake git

What these packages do:

  • build-essential / Development Tools — GCC compiler and core build utilities
  • yasm, nasm — assemblers required for FFmpeg's optimized codec implementations
  • pkg-config — helps the build system locate library headers and link flags

Get the FFmpeg source

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

For production use, check out a stable release tag rather than using the master branch:

bash
git checkout release/7.1

The master branch may contain breaking changes. Stable releases are what you want for anything you're shipping.


Configuring the Build

Configure options for a redistributable build

The ./configure invocation is where you decide what's included. Here's a configuration that enables patent-free codecs and excludes ones with redistribution restrictions:

bash
./configure \
    --prefix=/usr/local \
    --disable-nonfree \
    --enable-shared \
    --disable-static \
    --disable-debug \
    --enable-libvorbis \
    --enable-libopus \
    --enable-libvpx \
    --disable-libx264 \
    --disable-libx265 \
    --disable-libmp3lame \
    --disable-libfdk-aac

Important: This example doesn't specify --enable-gpl or --disable-gpl. By default, FFmpeg builds under LGPL. If you add --enable-gpl, the build is licensed under GPL, which has different redistribution requirements. Verify your project's legal requirements before choosing.

Options explained

OptionEffect
--prefix=/usr/localInstallation directory
--disable-nonfreeExclude proprietary, non-redistributable components
--enable-sharedBuild as shared libraries (.so) — required for LGPL compliance
--disable-staticDon't build static archives
--disable-libx264Exclude H.264 encoder (patent-encumbered)
--disable-libx265Exclude H.265 encoder (patent-encumbered)
--disable-libmp3lameExclude MP3 encoder
--disable-libfdk-aacExclude AAC encoder (Fraunhofer license)
--enable-libvpxEnable VP8/VP9 (patent-free)
--enable-libopusEnable Opus audio codec (patent-free)
--enable-libvorbisEnable Ogg Vorbis audio codec (patent-free)

Install codec development libraries first

The codec libraries need to be installed before running configure:

bash
# Ubuntu / Debian
sudo apt install libvpx-dev libopus-dev libvorbis-dev

# CentOS / RHEL (may need EPEL)
sudo yum install libvpx-devel opus-devel libvorbis-devel

# Arch Linux
sudo pacman -S libvpx opus libvorbis

Compiling and Installing

Run the build

bash
make -j$(nproc)

-j$(nproc) enables parallel compilation across all available CPU cores. Building FFmpeg typically takes 5–15 minutes depending on hardware.

Note: The build is CPU and memory intensive. On shared servers, this may be noticeable.

Install

bash
sudo make install

With --prefix=/usr/local, this puts:

  • Binaries in /usr/local/bin/ (ffmpeg, ffprobe, ffplay)
  • Libraries in /usr/local/lib/
  • Headers in /usr/local/include/

Verify PATH and installation

bash
which ffmpeg
ffmpeg -version

If command not found:

bash
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Make sure shared libraries are registered with the system linker:

bash
sudo ldconfig

License Verification

Check your build configuration

bash
ffmpeg -version

Look at the configuration: line in the output. Verify:

  • --disable-nonfree is present
  • libx264, libfdk_aac, libmp3lame are NOT listed
  • Your intended codecs (libvpx, libopus, etc.) ARE listed

LGPL redistribution requirements

If you're distributing under LGPL, you must:

  1. Include COPYING.LGPLv2.1 with your distribution (found in FFmpeg's source root)
  2. Mention that your product includes FFmpeg under the LGPL in your documentation
  3. Distribute FFmpeg as shared libraries (.so), not statically linked into your binary
  4. Allow end users to replace the FFmpeg library (re-link compatibility)

Troubleshooting

nasm/yasm not found or too old

bash
# Ubuntu/Debian
sudo apt install nasm yasm

# CentOS/RHEL
sudo yum install nasm yasm

# Arch Linux
sudo pacman -S nasm yasm

If the version from the package manager is too old, build from source from https://www.nasm.us/.

pkg-config: missing dependency or similar

You need the -dev (Debian) or -devel (Red Hat) headers package:

bash
sudo apt install libvpx-dev libopus-dev libvorbis-dev

make: *** [libavcodec] Error 1

Look at the error message above it for the specific failure. Then:

bash
# Clean and retry
make clean
./configure [same options]
make -j$(nproc)

# Check config log for detailed error
tail -100 ffbuild/config.log

command not found after installation

bash
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

Packaging for Distribution

tar.gz (simplest)

bash
# Build to a bundle directory
./configure --prefix=$(pwd)/bundle ...
make -j$(nproc)
make install

# Package with license files
cp COPYING.LGPLv2.1 bundle/
tar czf ffmpeg-redistributable-linux-x64.tar.gz bundle/

.deb package (Debian/Ubuntu)

Use checkinstall to create a .deb from make install:

bash
sudo apt install checkinstall
sudo checkinstall --pkgname=ffmpeg-custom --pkgversion=7.1 make install

.rpm package (CentOS/RHEL)

Use fpm (a packaging utility) for RPM creation:

bash
gem install fpm
fpm -s dir -t rpm -n ffmpeg-custom -v 7.1 \
    --prefix /usr/local \
    bundle/=/usr/local

Automating with CI/CD

GitHub Actions example

yaml
name: Build FFmpeg
on:
  push:
    branches: [main]
  schedule:
    - cron: '0 0 1 * *'  # Monthly rebuild

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Install dependencies
      run: |
        sudo apt update
        sudo apt install -y yasm nasm build-essential pkg-config git \
          libvpx-dev libopus-dev libvorbis-dev

    - name: Clone FFmpeg stable release
      run: |
        git clone https://git.ffmpeg.org/ffmpeg.git
        cd ffmpeg && git checkout release/7.1

    - name: Configure and build
      run: |
        cd ffmpeg
        ./configure \
          --prefix=$(pwd)/bundle \
          --disable-nonfree \
          --enable-shared \
          --disable-libx264 \
          --disable-libx265 \
          --enable-libvpx \
          --enable-libopus
        make -j$(nproc)
        make install

    - name: Package
      run: |
        cp ffmpeg/COPYING.LGPLv2.1 ffmpeg/bundle/
        tar czf ffmpeg-linux-x64.tar.gz -C ffmpeg bundle/

    - name: Upload artifact
      uses: actions/upload-artifact@v4
      with:
        name: ffmpeg-redistributable
        path: ffmpeg-linux-x64.tar.gz

Docker for reproducible builds

dockerfile
FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
    build-essential yasm nasm pkg-config libtool autoconf automake cmake git \
    libvpx-dev libopus-dev libvorbis-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /build

RUN git clone https://git.ffmpeg.org/ffmpeg.git && \
    cd ffmpeg && git checkout release/7.1 && \
    ./configure \
        --prefix=/usr/local \
        --disable-nonfree \
        --enable-shared \
        --enable-libvpx \
        --enable-libopus && \
    make -j$(nproc) && \
    make install && \
    ldconfig

ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

CMD ["ffmpeg", "-version"]

Build with:

bash
docker build -t ffmpeg-redistributable .
docker run --rm ffmpeg-redistributable

Summary

Building a redistributable FFmpeg on Linux comes down to these key decisions:

  1. Choose your license level: LGPL (no --enable-gpl) if you need the most permissive terms
  2. Exclude patented codecs: Always disable libx264, libx265, libmp3lame, libfdk-aac
  3. Use shared libraries: --enable-shared --disable-static for LGPL compliance
  4. Build from a stable tag: Don't use master for production binaries
  5. Include license files: Bundle COPYING.LGPLv2.1 with every distribution

For ongoing maintenance, automate the build process with GitHub Actions or Docker. This ensures you can quickly rebuild with security patches when they're released, and maintains a verifiable, reproducible build configuration.

When in doubt about specific license requirements for your use case, consult a legal professional familiar with open-source licensing.