How to Use rav1e Low Latency Mode in FFmpeg

This article provides a straightforward guide on how to configure the low-latency mode in the rav1e AV1 encoder using FFmpeg. You will learn the exact command-line parameters, speed settings, and configuration steps required to optimize your AV1 encodes for real-time streaming and interactive video applications.

The Low-Latency Command

To enable low-latency encoding in FFmpeg using the librav1e wrapper, you must pass the low_latency=true parameter via the -rav1e-params option.

Here is the standard command-line template:

ffmpeg -i input.mp4 -c:v librav1e -rav1e-params low_latency=true -speed 8 -c:a copy output.mp4

Key Parameter Breakdown

  • -c:v librav1e: This specifies that you are using the rav1e encoder library to encode the video.
  • -rav1e-params low_latency=true: This is the core setting. Enabling low_latency forces the encoder to disable frame reordering (B-frames) and minimizes the look-ahead buffer. This drastically reduces the time between input frames and output packets, which is essential for live streaming.
  • -speed 8: Speed settings in rav1e range from 0 (slowest, highest quality) to 10 (fastest, lowest quality). For low-latency and real-time use cases, you should use a speed setting of 5 or higher (typically 8 to 10 depending on your hardware capabilities) to ensure the encoder can process frames fast enough to prevent buffering.

Additional Optimizations for Live Streaming

If you are using low-latency mode for live streaming (e.g., via RTMP or WebRTC), you should pair the low-latency flag with real-time rate control. You can achieve this by setting a constant bitrate (CBR):

ffmpeg -i input.mp4 -c:v librav1e -b:v 2M -rav1e-params low_latency=true:strict_rc=true -speed 9 output.mp4
  • -b:v 2M: Sets the target video bitrate to 2 Mbps.
  • strict_rc=true: Adding this inside the -rav1e-params string forces strict rate control, preventing bitrate spikes that could cause latency over network connections.