Configure GOP Size in FFmpeg libsvtav1

This article explains how to configure the Group of Pictures (GOP) size, also known as the keyframe interval, when encoding video using the libsvtav1 encoder in FFmpeg. You will learn the specific command-line parameters required to set both standard and encoder-specific GOP boundaries to optimize your AV1 video compression for streaming or archiving.

The Standard FFmpeg Method

The easiest and most common way to set the GOP size in FFmpeg is by using the generic -g flag. This flag defines the maximum distance between keyframes (I-frames).

For example, to set a maximum GOP size of 240 frames (which equals 10 seconds of video at 24 frames per second):

ffmpeg -i input.mp4 -c:v libsvtav1 -g 240 output.mkv

The SVT-AV1 Parameter Method

Alternatively, you can pass parameters directly to the SVT-AV1 encoder using the -svtav1-params option. The internal parameter for the GOP size in SVT-AV1 is keyint.

To set the keyframe interval using this method, use the following command:

ffmpeg -i input.mp4 -c:v libsvtav1 -svtav1-params keyint=240 output.mkv

Setting a Strict/Fixed GOP Size

By default, SVT-AV1 uses scene change detection to insert keyframes dynamically at scene cuts, which can result in a variable GOP size shorter than your maximum limit. If you require a strict, fixed GOP size (crucial for adaptive bitrate streaming protocols like DASH or HLS), you must disable scene change detection.

You can achieve a fixed GOP size by disabling scene detection (scdet=0 or sc_detection=0 depending on your SVT-AV1 version) inside the -svtav1-params argument:

ffmpeg -i input.mp4 -c:v libsvtav1 -g 240 -svtav1-params scdet=0 output.mkv