Configure rav1e Min Keyframe Interval in FFmpeg
This article provides a quick guide on how to configure the minimum
keyframe interval (also known as minimum GOP size) when encoding AV1
video using the rav1e (librav1e) encoder in
FFmpeg. You will learn the exact command-line flags required to control
keyframe placement, helping you optimize video compression efficiency
and playback seekability.
To configure the minimum keyframe interval in FFmpeg with the
rav1e encoder, you can use either standard FFmpeg options
or the encoder’s native private parameters.
Method 1: Using Standard FFmpeg Flags
FFmpeg maps its generic keyframe interval flags directly to the
librav1e library. You can set the maximum keyframe interval
using -g and the minimum keyframe interval using
-keyint_min.
Here is an example command:
ffmpeg -i input.mp4 -c:v librav1e -g 240 -keyint_min 24 output.mp4In this command: * -c:v librav1e specifies the Rust AV1
encoder. * -g 240 sets the maximum interval between
keyframes to 240 frames. * -keyint_min 24 sets the minimum
interval between keyframes to 24 frames (preventing the encoder from
placing keyframes too close together, which wastes bitrate).
Method 2: Using rav1e Private Parameters
Alternatively, you can pass parameters directly to the
rav1e engine using the -rav1e-params option.
The internal parameter for the minimum keyframe interval is
min-keyint, and the maximum is keyint.
Here is the equivalent command using private parameters:
ffmpeg -i input.mp4 -c:v librav1e -rav1e-params keyint=240:min-keyint=24 output.mp4When passing multiple parameters via -rav1e-params,
separate each key-value pair with a colon (:). This method
is highly reliable as it bypasses generic FFmpeg translations and
communicates directly with the underlying rav1e API.