I am using Ubuntu Bionic Beaver 18.04 LTS and I would like to create high quality AV1 files using FFmpeg and librav1e. I have been spurred along by the recent addition of rav1e support to FFmpeg as librav1e.

The material that I am interested in working with is given here:

  1. Sintel trailer video (720p uncompressed 1.7GB)
  2. Sintel trailer audio (flac 5MB)

It is very early days (November 2019) for rav1e support under FFmpeg with not a lot of documentation and published experimentation in place yet. It would be great to see it all working under an Ubuntu LTS release!

  • As it were was looking at this recently. cargo produces a binary which doesn't seem what ffmpeg desires. cargo-c produces .h, .a & .pc files which seems correct but can't get ffmpeg to use... – doug Nov 16 '19 at 6:36
  • @doug I have packaged (for my own use) on my other distro with the following: cargo cinstall --release --destdir=$PKG --prefix=/usr --libdir=/usr/lib$LIBDIRSUFFIX and the release rav1e 0.1 which was accepted by FFmpeg ok. Difficult to package cleanly with all of the 'crates' downloading... – andrew.46 Nov 16 '19 at 8:57
  • Here in 18.04 the repo rustc & cargo are too old it seems. Using rustup gets a working compiler & packager but they are 'installed' to $HOME . So the cinstall works to the point of actually installing where it fails as no permission to install to /usr*. May try again like we used to do for vlc & ffmpeg, I.e keeping the whole build(s) in $HOME – doug Nov 16 '19 at 19:33
  • @doug Removal of the shared libraries seems to do the trick. I am not sure how to tell cargo cinstall not to build these so manual work necessary atm. Also some oddness with installation paths and 'prefix' which I have remedied... – andrew.46 Nov 22 '19 at 7:09

It looks like this goal can be accomplished in 4 relatively easy steps, thus allowing Bionic Beaver 18.04 LTS to get to grips with AV1 encoding with FFmpeg and rav1e!

1. Get a recent copy of rust...

Bionic Beaver has a copy of rust that is too old so grab a newer copy as follows:

sudo apt-get install curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Follow the defaults (just press 'enter') and then run:

source ~/.profile

to allow instant access to the newest rust and friends.

2. Install rav1e

Best to install both the executable (the command rav1e --fullhelp will then show options that can be used from within FFmpeg with the -rav1e-params option) as well as the libraries that FFmpeg will use to successfully compile and produce librav1e.

First the executable, using a simple copy and paste code block:

sudo apt-get install nasm && 
mkdir -pv $HOME/{bin,ffmpeg_sources,ffmpeg_build} && 
cd $HOME/ffmpeg_sources && 
wget https://github.com/xiph/rav1e/archive/v0.3.1.tar.gz && 
tar xvf v0.3.1.tar.gz && cd rav1e-0.3.1 && 
cargo build --release && 
find target -name rav1e -exec install -m 755 {} $HOME/bin \; && 
strip ~/bin/rav1e

Next install the cargo-c applet as well as the libraries and pkg-config file needed by FFmpeg. First run a one-off command to install cargo-c:

cargo install cargo-c

and then compile rav1e again using the installed cargo-c:

cd $HOME/ffmpeg_sources/rav1e-0.3.1 && 
cargo cinstall --release \
     --prefix=$HOME/ffmpeg_build \
     --libdir=$HOME/ffmpeg_build/lib \

Best to then remove the rav1e shared libraries, leaving the static libraries for FFmpeg to pick up:

rm -v $HOME/ffmpeg_build/lib/librav1e.so*

3. Install FFmpeg

Now go to the FFmpeg trac site and install FFmpeg as instructed, remembering to add:


to the ./configure string. Then the hard work is done :)

4. Run the encoder

A very reasonable encode can then be run on the test files mentioned in the original question:

ffmpeg -i sintel_trailer_2k_720p24.y4m -i sintel_trailer-audio.flac \
       -c:v librav1e -qp 80 -speed 4 \
       -tile-columns 2 -tile-rows 2 \
       -c:a libfdk_aac -b:a 128k \

Things to manipulate here would be:

  • -qp 80: Uses 'quantizer' mode to encode with a range of 0-255. Smaller values are a higher quality, the default is 100. 80 seems to be the sweet spot for this media clip.
  • -speed 4: Selects the speed preset (0-10) to encode with, 0 is best quality while 10 is the fastest. This particular setting is a nice compromise between speed and quality on my system (2nd generation Threadripper).
  • -tile-columns 2 -tile-rows 2 Quite decent speed enhancements can be made by manipulating rav1e's tile based encoding. The example given here splits the encoding and decoding into 4 segments and seems a decent choice for the suggested input video, feel free to experiment though..

This encodes at many times the speed that is seen with FFmpeg and libaom-av1 and arguably produces far better quality. Doubtless this encoding string can be further refined and I will do this as rav1e, FFmpeg and AV1 encoding mature...

5. Gratuitous screenshot

OK so there is an optional 5th step; taking a screenshot of the completed output file running :)

enter image description here

Additional Notes...

  • Encoding Time: Encoding to av1 is notoriously slow, not unexpected in these early days. By adding the command time in front of the suggested command line some interesting statistics can be generated:

    FFmpeg + rav1e 0.3.1    FFmpeg + rav1e 0.2.1  FFmpeg + rav1e 0.2.0
    real    10m50.144s      real    15m22.059s    real   14m22.045s
    user    42m20.816s      user    50m40.257s    user   48m32.285s
    sys     2m5.363s        sys     0m52.360s     sys    0m49.788s

    This is on a 2nd generation Threadripper computer specifically built for video encoding, your own figures will doubtless differ...

  • FFmpeg Documentation: The docs on the FFmpeg implementation of encoding with rav1e, this can also be seen by searching the FFmpeg man pages, either man ffmpeg-all or man ffmpeg-codecs. Remember that native rav1e options can be seen with rav1e --help and added into any FFmpeg command line by using the -rav1e-params option...

  • FFmpeg and Blender's short movie 'Sintel'...: My own page which uses the Sintel trailer for not only AV1 encoding but also for encoding with VP9, Theora and GPU H.264 encoding. Interesting if you want to extend your encoding knowledge or perhaps simply play with Sintel a bit more...

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.