rav1e

From wiki.selur.net
Jump to navigation Jump to search

rav1e is an AV1 encoder written in Rust, developed at Xiph.Org. AV1 is a royalty-free format that compresses clearly better than H.264. rav1e has few options and aims at safe, predictable encoding; it is slower than SVT-AV1 at comparable quality. Hybrid drives the command line encoder.

Base → Video: rav1e, then the rav1e tab

What it does

rav1e predicts each frame from already coded frames or from neighbouring blocks, transforms what is left and quantizes it. How coarse the quantization is decides size and quality. Hybrid offers these modes:

  • specific filesize/bitrate (2-pass): a first pass collects statistics, the second distributes a given bit rate or file size over the video. The two single entries 2pass - 1st pass and 2pass - 2nd pass run only that pass.
  • average bitrate (1-pass): one pass towards a bit rate.
  • constant quantizer (1-pass): a fixed base quantizer; the size results from the content. The usual choice when no size has to be hit.

Apart from the mode, the speed level is the setting that matters most.

Requirements

rav1e is part of Hybrid. In Hybrid it encodes 8-bit YUV 4:2:0; other sources are converted before they reach the encoder. AV1 goes into Matroska, WebM and MP4.

Settings

The option column shows the rav1e option a control ends up as.

Base

rav1e Base tab
rav1e Base tab

General Settings

Control rav1e option Range / values Hybrid default Meaning
Encoding mode --bitrate, --quantizer, --first-pass, --second-pass specific filesize/bitrate (2-pass), specific filesize/bitrate (2pass - 1st pass), specific filesize/bitrate (2pass - 2nd pass), average bitrate (1-pass), constant quantizer (1-pass) specific filesize/bitrate (2-pass) Rate control mode, see above.
Bitrate (kbit/s) --bitrate 16 – 245760 on, 1500 Target bit rate of the bit rate based modes. Only shown in these modes.
Target size (MiB), Target mode --bitrate 0.2 MiB and up; custom, 1/4 CD … 1 BD 50 off; custom, 700 Aim at a file size instead; Hybrid computes the video bit rate from the size, the length and the size of audio and other streams. Target mode offers common media sizes. Only for the 2-pass modes.
Quantizer --quantizer 0 – 255 100 Base quantizer of the constant quantizer mode; smaller values give higher quality and bigger files. Only shown in that mode.

Other settings

Control rav1e option Range / values Hybrid default Meaning
Tune --tune Psnr, Psychovisual Psychovisual What the encoder optimizes for: the measured error (PSNR) or the visual impression, which keeps more texture and grain. Use Psnr only for metric comparisons.
Speed --speed 0 – 10 3 Speed level: 0 is the slowest with the best compression, 10 the fastest. rav1e's own default is 6; the two extremes are not recommended by rav1e.
Threads --threads 0 – 1024 0 Size of the thread pool; 0 uses the number of logical CPUs. rav1e may use fewer threads than allowed.

Format

Control rav1e option Range / values Hybrid default Meaning
In-Output bit-depth – 8-bit, 10-bit, 12-bit 8-bit Bit depth of the video that is fed to the encoder. The control is locked; Hybrid converts the video to 8 bit.
Color sampling – i420, i422, i444 i420 Chroma subsampling of the video that is fed to the encoder. The control is locked; Hybrid converts the video to 4:2:0.

VUI

rav1e VUI tab
rav1e VUI tab

These settings only describe the video in the stream; they do not convert anything.

Control rav1e option Range / values Hybrid default Meaning
Primaries --primaries bt709, unspecified, bt470m, bt470bg, bt601, smpte240, film, bt2020, smpte428, smpte431, smpte432, ebu3213 unspecified Color primaries. The list is locked; Hybrid takes the value of the video that reaches the encoder.
Transfer --transfer bt1886, unspecified, bt470m, bt470bg, bt601, smpte240, linear, log100, log316, xvycc, bt1361, srgb, bt2020-10, bt2020-12, pq, smpte428, hlg, bt709 unspecified Transfer function (gamma). pq and hlg are the HDR ones. This one is set by hand.
Matrix --matrix unspecified, fcc, bt470bg, bt601, smpte240, ycgco, bt2020-ncl, bt2020-cl, smpte2085, chroma-ncl, chroma-cl, ictcp, bt709 bt709 Matrix for the YUV ↔ RGB conversion. The list is locked; Hybrid takes the value of the video that reaches the encoder.
Signal HDR – on/off off Switches the two HDR metadata entries below on.
Mastering Display --mastering-display text empty Mastering display metadata in the form G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min): primaries, white point and luminance range of the display the video was graded on. Take it from the source. Only with Signal HDR; not written when empty.
Light (maxCLL/Fall) --content-light 0 – 65535 each 0 / 0 Content light level: brightest pixel (MaxCLL) and highest frame average (MaxFALL) in cd/m². Only with Signal HDR; not written when both are 0.

Some list entries are passed under rav1e's own names, e.g. pq as SMPTE2084, bt1886 as BT709 and film as GenericFilm.

Misc

rav1e Misc tab
rav1e Misc tab
Control rav1e option Range / values Hybrid default Meaning
Minimize command line – on/off on Leaves out options that equal rav1e's own default (quantizer 100, speed 6, tune Psychovisual, min-keyint 12, keyint 240, threads 0, switch frame interval 0, unspecified color values).
Key interval (min/max) --min-keyint, --keyint 1 – 10000 each 1 / 240 Shortest and longest distance between key frames. rav1e's own minimum is 12; a minimum of 1 allows a key frame at every scene change. A shorter maximum makes seeking faster and files bigger.
RDO lookahead frames --rdo-lookahead-frames 0 – 1024 40 How many frames the encoder looks ahead for its rate-distortion decisions. More costs memory and time. rav1e's own default depends on the speed (10 to 40 frames); Hybrid always writes its value.
Reservoir frame delay --reservoir-frame-delay 12 – 1024 off, 240 Number of frames over which the rate control may spread its bit reservoir. Unchecked, rav1e uses min(240, 1.5 × maximum key interval) and the box shows that value. Smaller values keep the bit rate tighter, for streaming.
low latency --low-latency on/off off Disables frame reordering, so frames leave the encoder in input order. For live use; costs compression.
Switch frame interval --switch-frame-interval 0 – 1024 0 Maximum distance between switch frames, which let a player change between streams of different resolution or bit rate; 0 disables them. Only available with low latency.

The Configuration row below the tabs saves, loads and deletes named sets of all rav1e settings.

Example

2-pass with 1500 kbit/s, speed 3, key interval 1/240 on a 10-bit YUV 4:2:0 source (640x352, 25 fps), with Minimize command line on. Hybrid converts the video to 8 bit first:

vspipe "encodingTempSynthSkript.vpy" - --outputindex 0 -c y4m --progress | ffmpeg -y -loglevel fatal -noautorotate -nostdin -threads 8 -f yuv4mpegpipe -i - -an -sn -pix_fmt yuv420p -fps_mode auto -r 25/1 -f yuv4mpegpipe - | rav1e --first-pass "test.stats" --bitrate 1500 --speed 3 --min-keyint 1 --rdo-lookahead-frames 40 --matrix bt470bg - -o NUL
vspipe "encodingTempSynthSkript.vpy" - --outputindex 0 -c y4m --progress | ffmpeg -y -loglevel fatal -noautorotate -nostdin -threads 8 -f yuv4mpegpipe -i - -an -sn -pix_fmt yuv420p -fps_mode auto -r 25/1 -f yuv4mpegpipe - | rav1e --second-pass "test.stats" --bitrate 1500 --speed 3 --min-keyint 1 --rdo-lookahead-frames 40 --matrix bt470bg - -o "video.ivf"

How Hybrid calls it

  • rav1e reads y4m from a pipe. The filter script (Vapoursynth or AviSynth) is piped through ffmpeg, which delivers 8-bit 4:2:0 (-pix_fmt yuv420p), into rav1e.
  • rav1e writes an IVF file; Hybrid muxes it into the chosen container in a separate job.
  • In the 2-pass mode Hybrid creates one job per pass (--first-pass, --second-pass with the same statistics file), sends the output of the first pass to nowhere and removes the statistics file afterwards.
  • Speed, tune, key intervals, threads, RDO lookahead and the three color values are always part of the call; Minimize command line then strips those that equal rav1e's default. --rdo-lookahead-frames always stays.
  • --switch-frame-interval is only written together with --low-latency.

Background

Speed levels

The speed level decides which coding tools and how thorough a search rav1e uses. Lower levels compress better and take much longer. The default RDO lookahead of rav1e also changes with it: 10 frames at speeds 9 and 10, 20 at 6 – 8, 30 at 3 – 5 and 40 at 0 – 2.

Quantizer scale

rav1e's quantizer runs from 0 to 255 like the internal AV1 quantizer index, not from 0 to 63 like the scale of aomenc or SVT-AV1. Values are therefore not comparable between the encoders.

Sources

  • rav1e on GitHub
  • the built-in help of rav1e (rav1e --help)
  • Hybrid's tooltips