30
July
2024
17:42

Compiling dav1d video decoder

30 July 2024 17:42

Dav1d is the fastest AV1 video decoder for Windows, Linux and MacOS.

Introduction

On an ASUS "Eee PC" netbook running Linux LXLE, with an AMD E-350 processor and a Radeon HD 6250 video card, I have problems playing video: in the Google Chrome browser the video is interrupted. The solution is to first download the video and then play it from your hard drive using a video player mpv. Of course, mpv is sufficient for many tasks, but dav1d is more advanced - written in C. Comparison with other players here.
For those who do not want to compile, there is a ready-made solution see end of article- section "Using dav1d".

Ability to install dav1d from the Linux repository

The encoder/decoder is present in the Ubuntu repository

sudo apt update
sudo apt install dav1d

version from the repository:

dav1d --version

1.2.1

Looking ahead, the version after compilation turned out to be much newer:

dav1d --version

1.4.2-15-g2355eeb

dav1d home page and source code repository

dav1d home page located at VideoLAN.org

There is no binary file and you need to create it yourself by compiling the source texts.
The source code repository is on GitHub. To clone a repository to your disk:

git clone https://github.com/videolan/dav1d

Compilation Requirements

The following packages are needed:

  • build-essential
  • clang
    *meson
  • ninja

The first three conditions are satisfied by installing packages from the command line:

sudo apt install build-essential
sudo apt-get install clang
sudo apt-get install meson

As for ninja, there are two ways - install from the repository or download the latest version.

sudo apt-get install ninja-build

Or you can download the binary file for Linux-64bit from the ninja project page:
*https://github.com/ninja-build/ninja/releases.
I chose the second method - a binary file.

Official dav1d assembly guide

*VideoLAN - dav1d

Unofficial dav1d compilation procedure

1) After cloning from the repository, a folder appeared in the home directory ~/dav1d/. Let's go into it.
2) Open from the page https://github.com/ninja-build/ninja/releases and open the file in the archiver ninja-linux.zip and extract the ninja binary file to the directory ~/dav1d/.
3) Select the default compiler g+

sudo update-alternatives --config cc #select g+
sudo update-alternatives --config c++ #select g+

4) In the dav1d folder, create a “build” directory

mkdir build

5) Compilation

meson setup build

6) Build from object files in the build folder

cd build
../ninja

Result - the output file after compilation is located in the directory "~/dav1d/build/tools", executable file "dav1d".

7) Installing the binary file in the system directories

../ninja -C build install

The program will ask for superuser privileges to install the binary file. After entering the password, the dav1d executable file will be written to the /usr/local/bin directory:

Installing tools/dav1d to /usr/local/bin

Other compilation instructions

on the Christian Külker website

Using dav1d

The decoder is built into the player VLC starting from version 3.0.5 and is used to play movies in AV1 by default. The current version of VLC is 3.0.16.

sudo apt install vlc

And in the command line launch vlc to play the video

vlc video.mp4

Additional vlc keys can improve performance and playback quality (lower CPU usage, reduce frame drops) as written here.

dav1d does not play video directly. It is used in external video playback programs such as VLC and MPV.

Use in MPV player

According to mpv documentation the keys are responsible for video output

--vo=
Specify the video output backend to be used. See VIDEO OUTPUT DRIVERS for details and descriptions of available drivers.
--vd=<...>

  • video drivers separated by commas.

The latest version of MPV with dav1d support must be installed not from the Linux repository, but from Flatpak!

Installing the player mpv with the help Flatpack:

sudo add-apt-repository ppa:flatpak/stable

sudo apt update

sudo apt install flatpak

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

flatpak install flathub io.mpv.Mpv

flatpak run io.mpv.Mpv

Source:Reddit - AV1 videos are lagging like crazy(frame drops)

Or you can download the file from the FlatHub page flatpakref for mpv or install it using terminal commands:

wget https://dl.flathub.org/repo/appstream/io.mpv.Mpv.flatpakref
sudo flatpak install io.mpv.Mpv.flatpakref
flatpak run io.mpv.Mpv

Start playing a file in MPV

flatpak run io.mpv.Mpv video.mp4

How to download a file from YouTube.

There is an extension for the Mozilla FireFox web browser "Easy YouTube Video Downloader", which adds a button to download the video. Video saved from Mozilla Firefox you can watch it in any player after downloading, including when there is no Internet, for example, on a business trip.



Related publications