Force Strict Keyframe Interval in libsvtav1
Forcing a strict keyframe (GOP) interval in the SVT-AV1 encoder is
crucial for streaming protocols like HLS or DASH, where segment
alignment is required. This article provides a straightforward guide on
how to configure FFmpeg and libsvtav1 parameters to disable
scene change detection and enforce a fixed, predictable keyframe
interval.
To force a strict keyframe interval when using libsvtav1
in FFmpeg, you must set the minimum and maximum keyframe intervals to
your desired frame count and explicitly disable scene change detection.
By default, SVT-AV1 will insert extra keyframes at scene cuts, which
breaks strict intervals.
The FFmpeg Command
Use the following FFmpeg command template to enforce a strict keyframe interval:
ffmpeg -i input.mp4 -c:v libsvtav1 -g 120 -keyint_min 120 -svtav1-params scd=0 output.mp4Parameter Breakdown
-g 120: Sets the maximum keyframe interval (GOP size) to 120 frames. For a 60 fps video, this results in a keyframe every 2 seconds.-keyint_min 120: Sets the minimum keyframe interval to 120 frames. Matching this with the-gvalue prevents the encoder from placing keyframes closer together than desired.-svtav1-params scd=0: Disables Scene Change Detection (scd=0). This is the most critical step. Without disabling this, the encoder will still insert keyframes at scene transitions, disrupting the strict interval.
(Note: Depending on your FFmpeg and SVT-AV1 version, you can also
use sc-detection=0 instead of scd=0 in the
parameter string.)
Standalone SVT-AV1 Encoder (SvtAv1EncApp)
If you are using the standalone SvtAv1EncApp executable
instead of FFmpeg, use the following arguments to achieve the same
result:
SvtAv1EncApp -i input.y4m -b output.ivf --keyint 120 --scd 0By combining equal minimum/maximum interval values with the
deactivation of scene change detection, libsvtav1 will
output keyframes at the exact frame interval specified.