How to Compile FFmpeg with Lagarith Support

This guide provides a straightforward, step-by-step walkthrough on how to compile FFmpeg from source with support for the Lagarith lossless video decoder. You will learn how to prepare your build environment, configure the FFmpeg source code to ensure the Lagarith decoder is enabled, and compile and verify the final installation.

Step 1: Install System Dependencies

Before compiling FFmpeg, you must install the necessary build tools and assemblers (like nasm or yasm) required to compile the assembly code used in video decoders.

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

sudo apt update
sudo apt install build-essential git yasm nasm pkg-config libtool security-info

For Fedora/RHEL-based systems, use:

sudo dnf groupinstall "Development Tools"
sudo dnf install git yasm nasm pkgconfig

Step 2: Clone the FFmpeg Source Code

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

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

Step 3: Configure the Build

The Lagarith decoder is a native decoder within FFmpeg, meaning it does not require external third-party libraries to be installed on your system. It is enabled by default in standard builds. However, if you are doing a customized or minimal build, you must explicitly enable it.

Run the configure script with your desired flags. To ensure Lagarith is included, use the following configuration:

./configure --enable-gpl --enable-decoder=lagarith

If you want a highly customized, minimal build that only supports the Lagarith decoder, you can disable all decoders first and then enable Lagarith specifically:

./configure --disable-decoders --enable-decoder=lagarith

Step 4: Compile and Install

Once the configuration successfully completes, compile the source code using multiple CPU cores to speed up the process, and then install the binaries:

make -j$(nproc)
sudo make install

Step 5: Verify Lagarith Decoder Support

After the installation is complete, verify that the compiled version of FFmpeg successfully includes the Lagarith decoder. Run the following command:

ffmpeg -decoders | grep lagarith

If the installation was successful, the output will display:

 V_D... lagarith             Lagarith lossless video

The V indicates a video decoder, and the D indicates support for decoding. Your custom-compiled FFmpeg binary is now ready to decode Lagarith-encoded AVI files.