How to encode and playback video with the AV1 codec on Bionic Beaver (18.04)?

16,063

Solution 1

At the moment a stock standard installation of Bionic Beaver 18.04 will offer little support for either encoding or playback of AOMedia Video 1 (AV1) files. For the sake of testing this assertion I have created a test AV1 file here:

wget http://www.andrews-corner.org/samples/askubuntu_test_aom.mp4

Support for AV1 files in Bionic Beaver at this time (August 5th 2018) was tested with this sample file in the following packages and versions:

  1. mediainfo: Downloaded from the Bionic Beaver Repository offers 'out of the box' support for AV1 files.
  2. vlc: Downloaded from the Bionic Beaver Repository does not support AV1 files. This support could be compiled in from vlc version 3.0 and greater. See screenshot below...
  3. SMPlayer: Bionic Beaver version offers no support for AV1.
  4. mpv: Bionic Beaver version offers no AV1 support.
  5. FFmpeg: Two points here:
    1. The Bionic Beaver version with extra codecs offers no support for AV1.
    2. Full support can be gained by following the FFmpeg Trac Compile Guide and has been possible since version 4.0. Files can be created and then played back with FFplay.
  6. Chrome: Again 2 points here:
    1. Chrome is not available from the Bionic Beaver Repositories.
    2. The -dev version of Chrome had no problems with playing the sample file. I tested Version 70.0.3510.0 (Official Build) dev (64-bit). Available as a direct download from Google, see screenshot below!
  7. Firefox: The Bionic Beaver Firefox cannot play AV1 files but support for AV1 should come with Firefox 63 when it is released...
  8. MKVToolNix: Two points:
    1. The Bionic Repository version does not deal adequately with AV1. It is version 19 while version 22 adds the required support.
    2. The developer has instructions to install the latest MKVToolNix under Bionic Beaver but I believe that most of the AV1 functionality even in this version is still waiting for the codec to mature. This caveat applies to versions 23 and 24 of MKVToolNix.

So that is the current state of play, a little dismal but things will improve as AV1 matures...

And the winner is:

enter image description here

Chrome!! For doing it all with the least fuss :)

Runner up:

enter image description here

Vlc!! For getting it all done, just waiting for the packagers to catch up :).

References:

  • Slackware Build for libaom: How the Slackware people build and package libaom. A few techniques there that would translate easily to the Ubuntu ways...

Solution 2

As of October 27, 2018, the easiest ways to get AV1 playback support are:

  • Going to Firefox's about:config page and setting media.av1.enabled to true. Firefox 63.0 and newer have built-in AV1 support but it's currently disabled by default.

  • Installing the Snap for the Beta version of the VLC 3.0.x series (currently 3.0.4-157-ga26ab1e) from the Snap Store. In the Store go All versions -> latest/beta -> install -> View in Desktop Store or via the command line:

    sudo snap install vlc --beta

  • Installing an up-to-date version of mpv. Their installation page links to this PPA. I don't really recommend this method since mpv currently has a bug that causes AV1 decoding to perform poorly.


Encoding is a whole another matter and currently a PITA. As of yet there is no way to get everything you'd like; FFmpeg can be compiled with AV1 support by following their Ubuntu compilation guide but the features required for multi-threaded encoding (namely -tile-columns and -tile-rows, and also -row-mt which is preferable) are currently not supported. Meaning that FFmpeg can only utilise one thread for AV1 encoding which makes things multiple times slower than normal. This has already lead to a misunderstanding about how slow AV1 encoding actually is and I don't really recommend this method.

Encoding by using the aomenc tool directly is the most realistic choice in terms of encoding speed, but you leave behind all the benefits of FFmpeg. aomenc only accepts raw video in the .y4m format which takes a massive amount of space, and obviously it can't encode audio. Speed is also an issue: at the fastest speed setting and a 1000k bitrate, 10 seconds of 1080p 24 fps video takes 13 minutes to encode. That's 0.32 frames encoded per second. The encoder's ability to utilise the CPU is also problem. With the fastest speed setting the average CPU usage of a 8-core Ryzen 1700X is about 21 percent. This rises to 41 percent when using the second slowest setting. So the encoder definitely isn't ready for widespread usage.

If you still want to try it, you need to compile it from source. You can adapt the libaom secton of the FFmpeg compilation guide or if you decided to compile FFmpeg, use the already-compiled aomenc that should be hanging out in the FFmpeg build directory.

To start with you'd convert your source video to y4m with FFmpeg. To convert 10 seconds of a video:

`ffmpeg -i input.mp4 -t 10 -pix_fmt yuv420p video.y4m

To encode you'd use a command that looks something like this:

aomenc --fps=24/1 -u 0 --codec=av1 --target-bitrate=1000 --lag-in-frames=25 --auto-alt-ref=1 -t 24 --cpu-used=8 --tile-columns=2 --tile-rows=2 --row-mt=1 -o output.webm video.y4m

I'd recommend waiting for FFmpeg to gain better support though. That will make encoding a much more realistic prospect.

Share:
16,063

Related videos on Youtube

xiota
Author by

xiota

Updated on September 18, 2022

Comments

  • xiota
    xiota almost 2 years

    Apparently, Chrome 69 beta includes support for the Alliance for Open Media AV1 codec. The feature seems pointless without the ability to encode video with the new codec.

    1. How can video be encoded with this new codec on Ubuntu 18.04?
    2. What is the status of playback support in other media players, such as mpv?
  • andrew.46
    andrew.46 almost 6 years
    @xiota Mind you FFmpeg only added AOM support in March this year so we are in very early days yet. git.videolan.org/…
  • doug
    doug over 5 years
    The launchpad.net/~mc3man/+archive/ubuntu/mpv-tests is now using libdav1d for decoding av1 files. Performance is greatly improved. Available for both 16.04 & 18.04
  • doug
    doug over 5 years
    Have some more 'challenging' samples I encoded here. (for a while..). They are encoded at about 30% of the orig. bitrate. Decoded for me best via libdav1d wget https://0x0.st/sxjk.tar