FFmpeg rav1e Speed and Quality Settings
This article explains how to configure the speed and quality parameters for the rav1e AV1 encoder when using FFmpeg. You will learn how to use specific command-line flags to control the encoding presets, set the constant quality level, and balance compression efficiency with processing time.
To encode video with rav1e in FFmpeg, you must specify the encoder
using -c:v librav1e. Controlling the output requires
adjusting two primary variables: encoding speed (presets) and output
quality (quantizer or bitrate).
Controlling Encoding Speed
The speed of the rav1e encoder is managed using the
-preset option.
- Range:
0to10 - Behavior: Lower numbers result in slower encoding speeds but significantly better compression efficiency (smaller file sizes at the same quality). Higher numbers result in faster encoding speeds at the expense of compression efficiency.
- Default: If not specified, FFmpeg defaults to a
preset level of
6.
For example, to run a high-quality but slow encode, use a lower preset:
ffmpeg -i input.mp4 -c:v librav1e -preset 3 output.mkvFor a fast test encode, use a higher preset:
ffmpeg -i input.mp4 -c:v librav1e -preset 8 output.mkvControlling Video Quality
To control the visual quality of the output, you can choose between Constant Quality (QP) mode or Target Bitrate mode.
1. Constant Quality Mode (Recommended)
Constant Quality mode ensures that every frame of the video meets a
specific quality threshold, regardless of how much bitrate is required
to achieve it. This is done using the -qp flag.
- Range:
0to255 - Behavior: Lower values yield higher visual quality
and larger file sizes. Higher values yield lower visual quality and
smaller file sizes. A value of
0represents lossless compression. - Recommended Range: For general high-definition web
video, values between
80and120offer a good balance of quality and file size.
Example command using Constant Quality:
ffmpeg -i input.mp4 -c:v librav1e -qp 100 -preset 5 output.mkv2. Target Bitrate Mode
If you need your output file to fit within a specific size
constraint, you can set a target bitrate using the -b:v
flag instead of using -qp.
Example command using Target Bitrate:
ffmpeg -i input.mp4 -c:v librav1e -b:v 2M -preset 6 output.mkvCombining Settings for Optimal Results
For most use cases, a combination of a medium-range preset and a constant quality value yields the best results. The following command balance speed and quality for a standard archival or streaming export:
ffmpeg -i input.mp4 -c:v librav1e -preset 5 -qp 90 -c:a copy output.mkvIn this command: * -c:v librav1e selects the rav1e AV1
encoder. * -preset 5 provides a balanced encoding speed. *
-qp 90 ensures a high level of visual fidelity. *
-c:a copy copies the audio stream without re-encoding to
save time and preserve original audio quality.