Thchere

How to Build and Use the dav2d Open-Source AV2 Decoder

Published: 2026-05-04 02:16:23 | Category: Programming

Introduction

The Alliance for Open Media had targeted an AV2 release by the end of 2025, but the specification remains in draft form. Nevertheless, VideoLAN developers have been actively working on dav2d, an open-source AV2 decoder, and recently published the code. This guide walks you through obtaining, building, and using dav2d to decode AV2 video streams. Whether you're a developer, enthusiast, or early adopter, you can now experiment with next-generation video compression.

How to Build and Use the dav2d Open-Source AV2 Decoder

What You Need

Before you begin, ensure you have the following:

  • A Unix-like operating system (Linux, macOS, or WSL on Windows)
  • Git (to clone the repository)
  • C compiler (GCC or Clang)
  • NASM (for assembly optimizations)
  • Meson build system (version ≥0.55)
  • Ninja build tool
  • Python 3 (for Meson scripts)
  • Basic command-line familiarity

Step-by-Step Guide

Step 1: Clone the dav2d Repository

Open your terminal and run:

git clone https://code.videolan.org/videolan/dav2d.git
cd dav2d

This downloads the source code. The repository contains the decoder, tools, and test files.

Step 2: Install Dependencies

Install the required system packages. On Debian/Ubuntu:

sudo apt update
sudo apt install build-essential git nasm meson ninja-build python3

On Fedora/RHEL:

sudo dnf groupinstall "Development Tools"
sudo dnf install git nasm meson ninja-build python3

On macOS (using Homebrew):

brew install git nasm meson ninja python

Make sure all tools are available (gcc --version, nasm --version, etc.).

Step 3: Configure the Build

dav2d uses Meson for configuration. Create a build directory and run Meson:

mkdir build
cd build
meson ..

Meson will detect dependencies and set up Ninja build files. If you want to enable extra options (like tests or debug symbols), use meson setup .. -Dtests=true -Ddebug=true. See meson_options.txt for all options.

Step 4: Compile the Decoder

Still inside the build directory, run:

ninja

This compiles the decoder library (libdav2d) and the command-line tool dav2d. The build may take several minutes. If any errors occur, check that all dependencies are installed and that you're using a supported compiler.

Step 5: Install the Decoder

Once compilation succeeds, install the library and tool system-wide:

sudo ninja install

This copies the shared library (libdav2d.so on Linux) and the dav2d executable to standard locations (e.g., /usr/local/lib and /usr/local/bin). On macOS the library extension is .dylib.

Step 6: Test the Installation

Verify that the decoder is correctly installed:

dav2d --version

You should see version information (e.g., dav2d 0.1.0). Also test with a sample AV2 bitstream (see Tips for where to get one):

dav2d -i sample.av2 -o output.y4m

This decodes sample.av2 into a Y4M video file. If the command completes without errors, the decoder works.

Step 7: Integrate into Your Projects

The libdav2d library is usable from C/C++ applications. Include the header <dav2d/dav2d.h> and link with -ldav2d. You can also use the dav2d command-line tool in scripts for batch decoding. For detailed API documentation, check the doc/ folder in the repository.

Tips

  • Obtain test clips: The AV2 conformance bitstreams are not yet widely released. You can generate simple AV2 sequences using the SVT-AV2 encoder (also open source). Alternatively, test with the sample files bundled in the dav2d repository under tests/.
  • Speed up compilation: Use ninja -j$(nproc) to utilize all CPU cores.
  • Debugging: If decoding fails, try dav2d -v -i input.av2 for verbose output.
  • Static build: To avoid runtime library issues, you can build dav2d statically with -Ddefault_library=static.
  • Contribute: dav2d is in early development. Report bugs or submit patches via the VideoLAN GitLab repository.
  • Stay updated: The AV2 specification is evolving. Regularly pull the latest dav2d code to support draft updates.

By following these steps, you can join the early adopters of AV2 decoding. As the standard matures, dav2d will become a critical component in open-source video players like VLC (also from VideoLAN). Happy decoding!