AV1 Keyframe Placement for Adaptive Bitrate Streaming

This article provides an overview of keyframe placement strategies used in AV1 encoding for adaptive bitrate (ABR) streaming workflows. It explores the technical necessity of aligning keyframes across bitrate ladders, evaluates fixed versus dynamic GOP structures, and examines AV1-specific features—such as Switch Frames (S-frames)—that optimize bandwidth efficiency without sacrificing smooth playback during network fluctuations.

The Role of Keyframes in Adaptive Bitrate Streaming

In adaptive bitrate streaming protocols like HLS and DASH, video streams are split into multi-second segments (typically between 2 to 6 seconds). A client device dynamically switches between high- and low-bandwidth renditions based on changing network conditions.

For seamless switching, every stream rendition in an encoding ladder must contain a keyframe (intra-frame) at the exact same presentation timestamp (PTS). If keyframes are misaligned, switching between bitrates causes playback artifacts, buffering, or decoder crashes because the decoder cannot find the required reference frames.

Fixed-Interval Closed GOPs

The standard approach for ABR streaming is the fixed-interval Closed Group of Pictures (GOP). In this strategy, keyframes are inserted at absolute, non-negotiable intervals matching the streaming segment length.

Scene-Aware Dynamic Keyframe Insertion

Enforcing keyframes only at fixed intervals can degrade visual quality when high-motion scene changes occur between segment boundaries. A dynamic keyframe strategy incorporates scene-cut detection alongside fixed boundaries.

AV1 Switch Frames (S-Frames)

AV1 introduces a specialized frame type designed specifically to solve the inefficiencies of traditional ABR keyframe placement: the Switch Frame (S-frame).

In traditional codecs, changing bitrates requires an IDR (Instantaneous Decoder Refresh) frame, which is an intra-coded frame that resets the reference buffer. Intra-frames require significantly more bits than inter-coded frames, causing periodic bitrate spikes at segment boundaries.

AV1 S-frames allow a video stream to switch to a different rendition without requiring a full intra-coded frame.

Open GOP Configurations in ABR

While Closed GOPs are standard for strict ABR segmentation, Open GOPs allow frames following a keyframe to reference frames that preceded it.

Best Practices for AV1 ABR Encoders

To maximize streaming stability and bandwidth efficiency in production AV1 workflows:

  1. Synchronize Segment Lengths: Match --keyint directly to the segment duration (e.g., --keyint 48 for 2-second segments at 24 fps).
  2. Standardize Decisions: If using two-pass encoding with dynamic scene detection, generate a first-pass analysis file and apply it uniformly across all renditions in the ladder to prevent boundary mismatches.
  3. Leverage S-Frames: When supported by the downstream packager and target client decoders, configure the AV1 encoder to use S-frames at segment switch points instead of full intra-only keyframes.