Video Streaming

6 min read

How to set the right Keyframe Interval for Streaming?

Explore Keyframe Interval and learn how to set it right and optimize your streaming quality. Discover how it works, and find the perfect balance between video quality and streaming efficiency.

Feature image
How to set the right Keyframe Interval for Streaming?

In today's world, streaming has become an essential part of our daily lives. As content creators, it is crucial to understand the technical aspects of streaming to provide the best possible quality to viewers. One of the key elements in streaming is the Keyframe Interval. This article will discuss the importance of keyframe intervals, how they work, and how to set the right one for your streaming needs.

What is a Keyframe interval?

A keyframe interval, or Group of Pictures (GOP) length, represents the temporal spacing between two successive keyframes in a video. Keyframes, or Intra-frames (I-frames), are individual frames containing complete and independent visual information, serving as reference points for other frames in the video sequence. The frames located between keyframes, known as Predictive frames (P-frames) and Bidirectional frames (B-frames), store only the changes or differences from the previous frame, allowing for efficient video data compression.

By adjusting the keyframe interval, one can control the trade-off between video quality and file size. A shorter keyframe interval, with more frequent keyframes, generally enhances video quality but results in larger file sizes due to the increased number of keyframes. Conversely, a longer keyframe interval reduces the number of keyframes, thereby reducing file size, but may lead to reduced quality as changes need to be propagated over a longer span of frames.

Keyframe Interval Example

How do you set a keyframe Interval?

The default keyframe interval is usually set by the encoding software, such as OBS or FFmpeg.

Setting Keyframe Interval with FFmpeg:

  1. Open a command prompt or terminal window.
  2. Navigate to the directory where FFmpeg is installed or included.
  3. Use the following command to set the keyframe interval:
ffmpeg -i input.mp4 -g <interval> output.mp4

Replace <interval> with the desired keyframe interval in frames. For example, if you want a keyframe every 5 seconds, and your video has a frame rate of 30 frames per second, set the interval to 150 (5 seconds * 30 frames per second). The command will take an input video file (input.mp4 in this example), set the specified keyframe interval, and create an output video file (output.mp4).

Setting Keyframe Interval with OBS Studio:

  1. Open OBS Studio and go to the "Settings" menu.
  2. Click on the "Output" tab in the left sidebar.
  3. Under the "Streaming" or "Recording" section, you'll find the "Keyframe Interval" option.
  4. Enter the desired keyframe interval in seconds. OBS allows you to set it as low as a second and as high as 60 seconds.
  5. Click "Apply" and "OK" to save the changes.

How does Keyframe Interval work?

In video compression, a keyframe interval determines how often complete frames, called keyframes or intra-frames (I-frames), are inserted into the video stream. These keyframes serve as reference points for other frames.

There are two types of frames between keyframes: Predictive frames (P-frames) and Bidirectional frames (B-frames). P-frames store only the changes or differences from the previous keyframe, while B-frames store the differences from the previous and subsequent keyframes or P-frames.

A shorter keyframe interval means more frequent keyframes, providing accurate reference points for the following frames. This generally improves video quality. However, it also increases file sizes and requires more bandwidth for streaming.

Conversely, a longer keyframe interval reduces the number of keyframes, resulting in smaller file sizes and reduced bandwidth requirements. However, longer intervals can lead to lower video quality and potential playback issues.

How to set the right Keyframe Interval for Streaming?

Finding the optimal keyframe interval for streaming is essential for ensuring a high-quality viewing experience while efficiently utilizing resources such as bandwidth and storage. Choosing the right keyframe interval depends on various factors, including the type of streaming (live or on-demand), the desired video quality, and the specific streaming platform requirements.

Best Keyframe Interval Settings for OBS

To change the keyframe interval in OBS, follow these steps:

1. Open OBS: Launch OBS on your computer and access your preferred scene or source settings.

2. Go to Output Settings: Click on "Settings" in the bottom-right corner, then select "Output" from the left-hand menu.

3. Choose the Encoder: Under the "Output" section, choose your preferred Encoder (e.g., x264, NVENC, or AMD VCE) from the drop-down menu. Different encoders may have slightly different settings, but the concept of Keyframe Interval remains consistent.

4. Set the Keyframe Interval: Look for the "Keyframe Interval" option in the Encoder settings.

  • For x264 (CPU-based Encoder): Set the Keyframe Interval to 2. If you experience network issues or high-latency connections, you can set it to 1, which may increase the bitrate requirement.
  • For NVENC (NVIDIA GPU-based Encoder): Set the Keyframe Interval to 2 or leave it at "Default" for most cases. NVIDIA's encoder usually handles this well on its own.
  • For AMD VCE (AMD GPU-based Encoder): Similar to NVENC, set the Keyframe Interval to 2 or leave it at "Default."

5. Apply the Changes: Once you've set the appropriate Keyframe Interval, click "Apply" to save the changes.

6. Test and Fine-Tune: After setting the Keyframe Interval, test your stream to ensure the video quality and streaming performance meet your requirements. You can fine-tune the settings based on your network conditions and viewer experience if necessary.

Live streaming and On-demand streaming

For live streaming, a lower keyframe interval (around 2 seconds) is recommended, as it provides better video quality and minimizes latency. On the other hand, on-demand streaming can benefit from a higher keyframe interval (5-10 seconds) to save on bandwidth and storage without significantly affecting the viewing experience.

Setting the right Keyframe Interval helps balance video quality and bandwidth usage during live streaming. Regular keyframes improve the quality while setting intervals too low might strain the network, leading to buffering issues for viewers. By following these steps, you can optimize your settings for a smooth and enjoyable streaming experience.

Relationship between Keyframes Interval and:

Video Compression

The Keyframe Interval and video compression are closely related in the context of video streaming and encoding.

Higher Keyframe Interval: A longer Keyframe Interval (e.g., 4 seconds or more) reduces the number of Keyframes inserted in the video stream, leading to higher compression efficiency. With fewer Keyframes, the file size of the video is reduced, which can be beneficial for streaming with limited bandwidth or storage limitations. However, higher Keyframe Intervals may negatively impact video quality during scenes with rapid motion or changes, as there are fewer reference points for decompression.

Lower Keyframe Interval: A shorter Keyframe Interval (e.g., 1 second) increases the frequency of Keyframes in the video stream, which improves video quality. With more frequent Keyframes, the video maintains a higher level of detail and clarity during motion-heavy scenes. However, a lower Keyframe Interval increases the bitrate requirement, as more data needs to be transmitted for each Keyframe. This can put a strain on the network, leading to buffering issues for viewers with limited bandwidth.

Finding the right balance between Keyframe Interval and video compression is crucial for optimizing streaming quality. In summary, the Keyframe Interval directly impacts video compression efficiency and video quality during streaming.


The relationship between Keyframe Interval and resolution involves finding the right balance between video quality and compression efficiency.

Higher Resolution: When streaming videos with higher resolutions (e.g., 1080p or 4K), it is generally advisable to have a relatively shorter Keyframe Interval. Higher resolutions contain more visual details, and frequent Keyframes help maintain video quality during motion or scene changes. Smaller Keyframe Intervals are preferred to prevent loss of detail during decompression and ensure a smooth playback experience.

Lower Resolution: For videos with lower resolutions (e.g., 720p or below), a longer Keyframe Interval might be sufficient without significantly compromising video quality. Since lower-resolution videos have fewer visual details, longer Keyframe Intervals can be used to increase compression efficiency and reduce file size, leading to more efficient streaming with limited bandwidth.

In conclusion, the relationship between Keyframe Interval and resolution involves finding the right balance between video quality and compression efficiency.


Setting the right keyframe interval is essential for optimizing video quality, file size, and streaming performance. Remember the type of streaming (live or on-demand), the resolution, and the bitrate when adjusting the keyframe interval. By understanding the relationship between keyframe intervals, video compression, and streaming requirements, content creators can deliver an improved viewing experience for their audience.


1. Is a lower keyframe interval better?
A lower keyframe interval can provide better video quality due to more frequent keyframes, but it may also increase file size and bandwidth usage. Consider your streaming needs and balance quality with bandwidth constraints when choosing the keyframe interval.

2. What is the average keyframe interval?
The average keyframe interval depends on the encoding software and preset but usually ranges between 2 and 10 seconds.

3. What is the keyframe interval of FFmpeg?
The default keyframe interval in FFmpeg can vary based on the selected codec and settings. You can set a custom keyframe interval using the "-g" option followed by the desired interval value in frames.

4. What is an IDR frame?
An IDR (Instantaneous Decoder Refresh) frame is a type of keyframe used in H.264 video compression. It serves as a reference point for subsequent frames and allows for random access in the video stream, enabling fast-forwarding or rewinding without decoding the entire video.

Images or Videos Loading Slow?

We compress them so your users don't need to wait.