Compile FFmpeg with libopencore-amr Support

Compiling FFmpeg with the libopencore-amr library enables support for encoding and decoding Adaptive Multi-Rate (AMR) audio formats, which are widely used in mobile telecommunications. This step-by-step guide walks you through installing the required dependencies, downloading the FFmpeg source code, configuring the build options, and compiling the binary to enable both AMR Narrowband (AMR-NB) and AMR Wideband (AMR-WB) support.

Step 1: Install Build Tools and Dependencies

Before compiling FFmpeg, you must install the necessary build tools and the development headers for the libopencore-amr library.

On Ubuntu or Debian-based systems, run the following command:

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

On Fedora or Red Hat-based systems, use:

sudo dnf groupinstall "Development Tools"
sudo dnf install yasm pkgconfig opencore-amr-devel

Step 2: Download the FFmpeg Source Code

Clone the official FFmpeg Git repository to obtain the latest source code:

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

Step 3: Configure FFmpeg

To enable libopencore-amr, you must explicitly tell the configure script to include the libraries. Because the OpenCORE AMR license (Apache License 2.0) is incompatible with GPL version 2, you must also pass the --enable-version3 flag.

Run the configuration command:

./configure \
  --enable-gpl \
  --enable-version3 \
  --enable-libopencore-amrnb \
  --enable-libopencore-amrwb

Note: You can append other configuration flags (like --enable-shared or --prefix=/usr/local) to this command depending on your specific requirements.

Step 4: Compile and Install

Once the configuration process completes without errors, compile the source code. You can use the -j flag to speed up compilation by utilizing multiple CPU cores:

make -j$(nproc)

After the compilation finishes, install the newly built FFmpeg binaries onto your system:

sudo make install

Step 5: Verify the Installation

To confirm that FFmpeg was compiled successfully with libopencore-amr support, check the installed codecs using the following command:

ffmpeg -decoders | grep amr

If the compilation was successful, the output will list both libopencore_amrnb and libopencore_amrwb as available decoders:

 A...D. amrnb                AMR-NB (Adaptive Multi-Rate Narrowband) (decoders: amrnb libopencore_amrnb )
 A...D. amrwb                AMR-WB (Adaptive Multi-Rate Wideband) (decoders: amrwb libopencore_amrwb )