I am currently using Ubuntu Focal Fossa 20.04 LTS and I would like to create high quality AV1 files using FFmpeg and librav1e. I have been spurred along by the addition of rav1e support to FFmpeg as 'librav1e'.
The material that I am interested in working with is given here:
- Sintel trailer video (720p uncompressed 1.7GB)
- Sintel trailer audio (flac 5MB)
It is early days for rav1e support under FFmpeg with not a lot of documentation and published experimentation in place. It would be great to see it all working under an Ubuntu LTS release!
It looks like this goal can be accomplished in 4 relatively easy steps, thus allowing Ubuntu Focal Fossa 20.04 LTS to get to grips with AV1 encoding with FFmpeg and rav1e!
1. Get a recent copy of rust...
Focal Fossa and rav1e benefit from a newer version of rust so grab a newer copy as follows:
Follow the defaults (just press 'enter') and then run the following to configure your current shell:
to allow instant access to the newest rust and friends. Remember to update this installation from time to time (especially if updating rav1e from this guide) by running:
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:
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 installcargo-c
:and then compile rav1e again using the installed
cargo-c
:Best to then remove the rav1e shared libraries, leaving the static libraries for FFmpeg to pick up (FFmpeg has a problem with the shared rav1e libraries in this location on my system):
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:
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 :)
Additional Notes...
man ffmpeg-all
orman ffmpeg-codecs
. Remember that native rav1e options can be seen withrav1e --help
and added into any FFmpeg command line by using the-rav1e-params
option...