How to Compile FFmpeg with libopencore-amr

Compiling FFmpeg with the libopencore-amr library enables support for encoding and decoding Adaptive Multi-Rate (AMR) speech audio codecs, which are standard in mobile telecommunications. This guide walks through the required dependencies, the configuration parameters needed for licensing compatibility, and the build steps to create a custom FFmpeg binary with both Narrowband (AMR-NB) and Wideband (AMR-WB) OpenCORE support.

1. Install Build Tools and Dependencies

Before compiling, install the build essentials, assembler tools, and the OpenCORE AMR development packages. On Debian-based distributions like Ubuntu, run:

sudo apt update
sudo apt install -y build-essential yasm nasm pkg-config git \
    libopencore-amrnb-dev libopencore-amrwb-dev

If compiling on Fedora, CentOS, or RHEL, install the packages via dnf:

sudo dnf install -y gcc gcc-c++ make yasm nasm pkgconfig git \
    opencore-amr-devel

2. Download the FFmpeg Source Code

Clone the official FFmpeg Git repository to get the latest source:

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

Alternatively, download and extract a specific release tarball from the FFmpeg releases archive.

3. Configure FFmpeg

libopencore-amr is licensed under the Apache License 2.0. Because the Apache 2.0 license is incompatible with GPL version 2, you must include the --enable-version3 flag during configuration.

Run the configure script with the required flags:

./configure \
  --prefix=/usr/local \
  --enable-version3 \
  --enable-libopencore-amrnb \
  --enable-libopencore-amrwb

If you plan to use GPL-licensed components alongside it, append --enable-gpl.

4. Compile and Install

Compile FFmpeg using all available CPU cores:

make -j$(nproc)

Once the compilation completes without errors, install the binaries to the prefix directory:

sudo make install

Update the system's shared library cache:

sudo ldconfig

5. Verify the Build

Confirm that FFmpeg was built with AMR support by checking the compiled configuration and available codecs:

ffmpeg -version

Look for --enable-libopencore-amrnb and --enable-libopencore-amrwb in the configuration output. You can also verify codec availability by running:

ffmpeg -codecs | grep -i amr

The output will display amr_nb and amr_wb with both decoding and encoding capabilities enabled.