Keyframes and GOP explained: why damaged video glitches, then recovers

By the FixMP4 engineering team · · 6 min read

If you have ever watched a damaged or freshly repaired video, you may have seen this: playback is fine, then the picture smears into grey or green blocks that follow the motion, and a second or two later everything snaps back to normal. That pattern is not random. It is a direct consequence of how modern video compression works.

Three kinds of frames

Codecs such as H.264 and HEVC do not store every frame as a full picture. That would make files ten to fifty times larger. Instead they use three types:

FrameStoresDepends on
I-frame (keyframe)A complete pictureNothing
P-frameChanges from earlier framesEarlier I/P frames
B-frameChanges from earlier and later framesFrames on both sides

A GOP (group of pictures) is the run of frames from one keyframe to the next. Cameras typically place a keyframe every half second to two seconds; screen recorders and streaming encoders often every two seconds.

Why damage spreads, then stops

When one frame is damaged, every frame that predicts from it inherits the error, and the frames that predict from those inherit it again. The error rides along with the motion, which is why you see blocks smearing in the direction things move. At the next keyframe the decoder receives a complete picture that depends on nothing, so the error disappears.

That has two practical consequences:

  • Short GOPs recover faster from damage.
  • All-intra codecs (ALL-I on Canon, XAVC S-I on Sony, ProRes) contain only keyframes, so damage stays confined to single frames.

B-frames and reordering

B-frames reference a later frame, so the encoder stores frames in decode order (the order the decoder needs them) rather than display order. The index of an MP4 records both: the decode timestamps and a "composition offset" for each frame. When a file loses its index, this information has to be reconstructed, otherwise playback stutters or frames appear in the wrong order.

Keyframes and seeking

Players can only start decoding cleanly at a keyframe. The MP4 index includes a sync sample table listing them, which is what makes the scrub bar jump quickly. A repaired file needs this table rebuilt, or seeking becomes slow or inaccurate.

What this means for a repaired recording

When the FixMP4 repair tool rebuilds a missing index, it:

  1. Identifies every frame in the media data from its NAL unit structure.
  2. Detects which frames are keyframes (IDR or IRAP pictures) and records them as sync samples.
  3. Works out display order and composition offsets for B-frames.
  4. Writes timestamps for every frame.

If the original media data was intact, the result plays perfectly. If part of the card or file was damaged, you will see the familiar smear-then-recover pattern at that spot, because those frames are genuinely damaged and no tool can recreate them. The good news is that everything from the next keyframe onward is clean.

The very first frames

A repaired file must start at a keyframe. If the recording's first frames were lost, the tool skips forward to the first complete keyframe, so you might lose a fraction of a second at the start.

A note on references

The reference clip used for a repair needs the same GOP structure only indirectly: matching the device, mode, resolution and frame rate ensures the encoder settings, including GOP length and B-frame use, are the same. See how to choose a reference file.

Summary

Keyframes are the reset points of compressed video. Damage spreads until the next one, and repairs depend on finding them correctly. If you see a brief smear in a repaired clip, it marks damaged data at that point, not a failed repair. For more on file structure, read what is the moov atom.

Frequently asked questions

What is a keyframe?

A frame stored as a complete picture (an I-frame). Other frames are stored as changes relative to keyframes and neighbouring frames.

Why does damaged video show grey blocks and then recover?

Frames after the damage depend on the damaged one. At the next keyframe the decoder gets a complete picture again and playback is clean.

Do all-intra recordings recover better?

Yes. In ALL-I footage every frame is a keyframe, so damage affects only individual frames.

Have a broken recording right now?

Diagnose it and hear or watch a free repaired preview. Nothing is uploaded.

Open the repair tool
  • keyframes
  • GOP
  • B-frames
  • H.264
  • glitches