How to Disable Libaom Decoder for Encoder-Only Build

This article provides a step-by-step guide on how to configure and build the Alliance for Open Media (AOM) AV1 codec library (libaom) as an encoder-only library by disabling its decoder functionality. By modifying the CMake configuration flags during the build setup, developers can significantly reduce the final binary size and eliminate unnecessary dependencies when only video encoding capabilities are required.

Understanding the Build Configuration

The libaom repository utilizes CMake as its meta-build system. By default, CMake compiles both the encoder and decoder components of the AV1 codec. However, for specialized deployment environments—such as cloud encoding pipelines, embedded devices, or specific application integrations—the decoding logic is often redundant. Disabling the decoder strips out the decoding algorithms, parsing logic, and static tables, resulting in a leaner library footprint.

Step-by-Step Guide to Disabling the Decoder

To compile an encoder-only version of libaom, you need to pass a specific boolean flag to the CMake command-line interface during the generation phase.

1. Prerequisites and Environment Setup

Before configuring the build, ensure you have the necessary build tools installed (cmake, git, and a compiler like gcc, clang, or MSVC). Clone the repository and navigate into the project directory:

git clone https://aomedia.googlesource.com/aom
cd aom

2. Create a Build Directory

It is best practice to perform an out-of-source build to keep the source tree clean.

mkdir build_encoder_only
cd build_encoder_only

3. Configure CMake with the Disable Flag

The critical configuration option to disable the decoder is CONFIG_AV1_DECODER. Setting this flag to 0 instructs CMake to exclude the decoding source files from the compilation targets.

Execute the following command to configure the build:

cmake .. -DCONFIG_AV1_DECODER=0

Note: If you also want to prevent the compilation of the standalone testing tools and examples that might rely on the decoder, you can additionally pass -DENABLE_EXAMPLES=0 and -DENABLE_TESTS=0.

4. Compile the Library

Once the configuration is successfully generated, compile the library using your system’s build tool.

For Unix-like systems (Linux, macOS):

make -j$(nproc)

For multi-configuration tools like Visual Studio on Windows:

cmake --build . --config Release

Verifying the Build Output

After compilation is complete, the resulting binaries (such as libaom.a, libaom.so, or aom.lib depending on your OS) will only contain the encoding symbols. You can verify this by checking the reduced file size compared to a standard build, or by inspecting the exported symbols using tools like nm or objdump to confirm the absence of decoder-specific functions (e.g., functions prefixed with aom_codec_dec).