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
sudoaccess
Install build dependencies
Ubuntu / Debian:
sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential yasm nasm pkg-config \
libtool autoconf automake cmake git
CentOS / RHEL:
sudo yum groupinstall -y "Development Tools"
sudo yum install -y yasm nasm pkgconfig libtool autoconf automake cmake git
Arch Linux:
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 utilitiesyasm,nasm— assemblers required for FFmpeg's optimized codec implementationspkg-config— helps the build system locate library headers and link flags
Get the FFmpeg source
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:
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:
./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
| Option | Effect |
|---|---|
--prefix=/usr/local | Installation directory |
--disable-nonfree | Exclude proprietary, non-redistributable components |
--enable-shared | Build as shared libraries (.so) — required for LGPL compliance |
--disable-static | Don't build static archives |
--disable-libx264 | Exclude H.264 encoder (patent-encumbered) |
--disable-libx265 | Exclude H.265 encoder (patent-encumbered) |
--disable-libmp3lame | Exclude MP3 encoder |
--disable-libfdk-aac | Exclude AAC encoder (Fraunhofer license) |
--enable-libvpx | Enable VP8/VP9 (patent-free) |
--enable-libopus | Enable Opus audio codec (patent-free) |
--enable-libvorbis | Enable Ogg Vorbis audio codec (patent-free) |
Install codec development libraries first
The codec libraries need to be installed before running configure:
# 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
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
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
which ffmpeg
ffmpeg -version
If command not found:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Make sure shared libraries are registered with the system linker:
sudo ldconfig
License Verification
Check your build configuration
ffmpeg -version
Look at the configuration: line in the output. Verify:
--disable-nonfreeis presentlibx264,libfdk_aac,libmp3lameare NOT listed- Your intended codecs (libvpx, libopus, etc.) ARE listed
LGPL redistribution requirements
If you're distributing under LGPL, you must:
- Include
COPYING.LGPLv2.1with your distribution (found in FFmpeg's source root) - Mention that your product includes FFmpeg under the LGPL in your documentation
- Distribute FFmpeg as shared libraries (
.so), not statically linked into your binary - Allow end users to replace the FFmpeg library (re-link compatibility)
Troubleshooting
nasm/yasm not found or too old
# 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:
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:
# 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
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig
Packaging for Distribution
tar.gz (simplest)
# 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:
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:
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
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
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:
docker build -t ffmpeg-redistributable .
docker run --rm ffmpeg-redistributable
Summary
Building a redistributable FFmpeg on Linux comes down to these key decisions:
- Choose your license level: LGPL (no
--enable-gpl) if you need the most permissive terms - Exclude patented codecs: Always disable libx264, libx265, libmp3lame, libfdk-aac
- Use shared libraries:
--enable-shared --disable-staticfor LGPL compliance - Build from a stable tag: Don't use master for production binaries
- Include license files: Bundle
COPYING.LGPLv2.1with 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.