How to Build and Use the dav2d Open-Source AV2 Decoder
By
<h2>Introduction</h2>
<p>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 <strong>dav2d</strong>, 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.</p><figure style="margin:20px 0"><img src="https://picsum.photos/seed/1878167746/800/450" alt="How to Build and Use the dav2d Open-Source AV2 Decoder" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px"></figcaption></figure>
<h2 id="what-you-need">What You Need</h2>
<p>Before you begin, ensure you have the following:</p>
<ul>
<li>A Unix-like operating system (Linux, macOS, or WSL on Windows)</li>
<li><strong>Git</strong> (to clone the repository)</li>
<li><strong>C compiler</strong> (GCC or Clang)</li>
<li><strong>NASM</strong> (for assembly optimizations)</li>
<li><strong>Meson</strong> build system (version ≥0.55)</li>
<li><strong>Ninja</strong> build tool</li>
<li><strong>Python 3</strong> (for Meson scripts)</li>
<li>Basic command-line familiarity</li>
</ul>
<h2>Step-by-Step Guide</h2>
<h3 id="step1">Step 1: Clone the dav2d Repository</h3>
<p>Open your terminal and run:</p>
<pre><code>git clone https://code.videolan.org/videolan/dav2d.git
cd dav2d</code></pre>
<p>This downloads the source code. The repository contains the decoder, tools, and test files.</p>
<h3 id="step2">Step 2: Install Dependencies</h3>
<p>Install the required system packages. On Debian/Ubuntu:</p>
<pre><code>sudo apt update
sudo apt install build-essential git nasm meson ninja-build python3</code></pre>
<p>On Fedora/RHEL:</p>
<pre><code>sudo dnf groupinstall "Development Tools"
sudo dnf install git nasm meson ninja-build python3</code></pre>
<p>On macOS (using Homebrew):</p>
<pre><code>brew install git nasm meson ninja python</code></pre>
<p>Make sure all tools are available (<code>gcc --version</code>, <code>nasm --version</code>, etc.).</p>
<h3 id="step3">Step 3: Configure the Build</h3>
<p>dav2d uses Meson for configuration. Create a build directory and run Meson:</p>
<pre><code>mkdir build
cd build
meson ..</code></pre>
<p>Meson will detect dependencies and set up Ninja build files. If you want to enable extra options (like tests or debug symbols), use <code>meson setup .. -Dtests=true -Ddebug=true</code>. See <code>meson_options.txt</code> for all options.</p>
<h3 id="step4">Step 4: Compile the Decoder</h3>
<p>Still inside the <code>build</code> directory, run:</p>
<pre><code>ninja</code></pre>
<p>This compiles the decoder library (<code>libdav2d</code>) and the command-line tool <code>dav2d</code>. The build may take several minutes. If any errors occur, check that all dependencies are installed and that you're using a supported compiler.</p>
<h3 id="step5">Step 5: Install the Decoder</h3>
<p>Once compilation succeeds, install the library and tool system-wide:</p>
<pre><code>sudo ninja install</code></pre>
<p>This copies the shared library (<code>libdav2d.so</code> on Linux) and the <code>dav2d</code> executable to standard locations (e.g., <code>/usr/local/lib</code> and <code>/usr/local/bin</code>). On macOS the library extension is <code>.dylib</code>.</p>
<h3 id="step6">Step 6: Test the Installation</h3>
<p>Verify that the decoder is correctly installed:</p>
<pre><code>dav2d --version</code></pre>
<p>You should see version information (e.g., <code>dav2d 0.1.0</code>). Also test with a sample AV2 bitstream (see Tips for where to get one):</p>
<pre><code>dav2d -i sample.av2 -o output.y4m</code></pre>
<p>This decodes <code>sample.av2</code> into a Y4M video file. If the command completes without errors, the decoder works.</p>
<h3 id="step7">Step 7: Integrate into Your Projects</h3>
<p>The <code>libdav2d</code> library is usable from C/C++ applications. Include the header <code><dav2d/dav2d.h></code> and link with <code>-ldav2d</code>. You can also use the <code>dav2d</code> command-line tool in scripts for batch decoding. For detailed API documentation, check the <code>doc/</code> folder in the repository.</p>
<h2 id="tips">Tips</h2>
<ul>
<li><strong>Obtain test clips:</strong> The AV2 conformance bitstreams are not yet widely released. You can generate simple AV2 sequences using the <a href="https://gitlab.com/AOMediaCodec/SVT-AV2">SVT-AV2</a> encoder (also open source). Alternatively, test with the sample files bundled in the dav2d repository under <code>tests/</code>.</li>
<li><strong>Speed up compilation:</strong> Use <code>ninja -j$(nproc)</code> to utilize all CPU cores.</li>
<li><strong>Debugging:</strong> If decoding fails, try <code>dav2d -v -i input.av2</code> for verbose output.</li>
<li><strong>Static build:</strong> To avoid runtime library issues, you can build dav2d statically with <code>-Ddefault_library=static</code>.</li>
<li><strong>Contribute:</strong> dav2d is in early development. Report bugs or submit patches via the VideoLAN GitLab repository.</li>
<li><strong>Stay updated:</strong> The AV2 specification is evolving. Regularly pull the latest dav2d code to support draft updates.</li>
</ul>
<p>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!</p>