A Keyframe in video compression is also known as an I-frame or Intra-frame.

Keyframes are frames that can be decompressed and displayed without relying on any other encoded frames. You can think of them as GIF or JPG images.

In general, video codecs don’t compress a sequence of still images. They use past and future frames as references during the compression process. This approach makes the compression a lot more effective, but has two drawbacks:

  1. It requires more resources (memory and CPU) to compress
  2. When there is packet loss, the whole stream becomes broken unless fixed (either using retransmissions, forward error correction, using temporal scalability, SVC or a fresh keyframe being sent)

For video compression, we try to keep a balance between resilience and the amount of keyframes we send.

A keyframe takes up large amounts of bitrate compared to other frame types (P-frame and B-frame which rely on past or future frame references). Due to this, we don’t want to use keyframes more than needed. On the other hand, packet losses will require us to send out keyframes, and until these are received, might freeze the video stream.

Video encoders can decide through configuration at what frequency to send keyframes (every 12 frames is a common approach for example). WebRTC has feedback messages such as FIR and PLI enabling the receiver to signal to the sender that they lost a frame and may need a fresh keyframe to be generated.

Additional reading

Tags: codec

Looking to learn more about WebRTC? 

Check my WebRTC training courses

About WebRTC Glossary

The WebRTC Glossary is an ongoing project where users can learn more about WebRTC related terms. It is maintained by Tsahi Levent-Levi of BlogGeek.me.