Back to Glossary
Video

I-Frame

Also known as: Intra frame, Intra-coded picture

What Is an I-Frame in Video?

An I-frame, short for intra-coded frame, is a frame of compressed video stored as a complete picture, so a decoder can rebuild it without any other frame. The frames between I-frames are stored as changes, and since decoding can only begin at a frame that stands alone, a player starts from an I-frame whenever a video opens or someone jumps to a new point.

In video compression, the I-frames a player can start from are also called keyframes, which is a different idea from the keyframes of an animation. An I-frame usually needs the most bits of the three frame types, so placing them often makes a file bigger, and quicker to start and to seek.

I

I-frames hold a complete picture

An I-frame is compressed the way a still image is, from its own pixels only. It usually needs the most data of the three types, and it is the only one a decoder can show without having decoded any other frame first.

P

P-frames store changes from earlier frames

A P-frame, for predicted, records how blocks moved or changed since a frame already decoded and reuses everything that stayed the same. It takes less data than an I-frame, and later frames can be predicted from it in turn.

B

B-frames borrow from both directions

A B-frame, for bidirectional, can combine parts of a frame before it and one after it, so it is usually the smallest of the three. The later frame has to be decoded first, so a file with B-frames stores its frames in a different order than it shows them.

What Is a GOP, and Is It Open or Closed?

A group of pictures, or GOP, is the run of frames from one I-frame to the next, and the GOP size is the distance between I-frames. In the pattern IBBPBBPBBPBB, a GOP of 12 frames repeats with a P-frame every third frame. H.264 and later codecs also mark some I-frames as IDR frames, short for instantaneous decoder refresh, meaning that no frame after one may refer to anything before it.

A closed GOP starts clean at its IDR frame

Every frame in a closed GOP refers only to frames inside it, so a decoder that starts at its IDR frame can show the whole group. AWS Elemental Live’s documentation recommends closed GOPs for streams cut into HLS or DASH segments, and Amazon IVS warns that a segment that doesn’t start on an IDR frame can show decode errors when viewers start playback.

An open GOP reaches back into the one before

The B-frames that play just before an open GOP’s I-frame borrow from the previous GOP, so that I-frame isn’t an IDR frame, and a decoder that starts there can’t rebuild them. AWS Elemental Live’s documentation recommends allowing them only for outputs that aren’t cut into segments, such as a single file.

Where Are the I-Frames in Your Video?

The map opens on a 5-second clip of ours, encoded with an I-frame every 2 seconds. Drag the slider to see how far back a decoder has to start for any frame. You can also map an MP4 or MOV of your own, and an H.264 file then shows its P- and B-frames as well, and which of its I-frames are IDR frames.

Map the frames of a video

See where the I-frames sit and what a jump to any frame costs a decoder.

An MP4 or MOV file, or drop one on this card. The file stays on your device: the page reads its frame index in your browser.

Showing a 5-second clip with an I-frame every 2 seconds.

Codec
H.264
Frames
121 over 5.04 s, at 24 fps
I-frames
3, all of them IDR
Time between I-frames
2 s (48 frames)
B-frames
Yes
Average frame size
I 54 KB, P 6.6 KB, B 1.3 KB

To show the frame at 3.5 s, a decoder starts at the I-frame at 2 s and decodes up to 35 frames.

I-frame P-frame B-frame

The first 96 frames in display order, from 0 to 3.96 s. Taller bars are bigger frames.

The map comes from the file's own frame index. For H.264, the page also reads each frame's type from its slice header; for other codecs it shows which frames are keyframes.

Why Does a Cut Without Re-Encoding Start Early?

Copying a video’s frames into a new file without decoding them keeps each frame exactly as it was, but the copy has to begin at an I-frame. Asked to start between two of them, ffmpeg goes back to the I-frame before that point, and its manual says a stream copy keeps the extra frames.

We cut a 10-second clip with an I-frame every 2 seconds at the 3-second mark, both ways. The copy kept all 240 frames from the I-frame at 2 seconds and marked the first 30 to be discarded, while the re-encode began with a new I-frame at 3 seconds and held 210 frames. To cut exactly without re-encoding, cut on an I-frame, or force one at that point when the video is encoded.

Cut at 3 seconds, then count frame types
# Stream copy: starts at the I-frame at 2 s, 240 frames
ffmpeg -ss 3 -i in.mp4 -c copy cut-copy.mp4
# Re-encode: starts at 3 s on a new I-frame, 210 frames
ffmpeg -ss 3 -i in.mp4 -c:v libx264 cut-reencode.mp4
# Count the I-, P- and B-frames in a file
ffprobe -v error -select_streams v:0 -show_entries frame=pict_type -of default=nw=1:nk=1 in.mp4 | sort | uniq -c

How Often Should a Video Have an I-Frame?

The right spacing comes from where the video goes next. A streamer sending 30 fps to a live platform, for example, sets an I-frame every 2 seconds, one every 60 frames, as YouTube Live and Amazon IVS both recommend.

  I-frame spacing How to set it up
Live streaming 2 seconds A fixed keyframe interval, at most 4 seconds for YouTube Live
YouTube upload Half a second A closed GOP of half the frame rate, 15 frames at 30 fps
HLS or DASH stream At least one per segment Closed GOPs, each segment starting on an IDR frame
Editing master Every frame An intra-only codec such as ProRes
Cut without re-encoding At each cut Force an I-frame at the cut point while encoding

Seeking, Trimming and Filmstrips in CE.SDK

Your app gives the Block API of CE.SDK video editing a time in seconds whenever it seeks, trims a clip or sets the range of a filmstrip.

Move playback to any time

setPlaybackTime moves a block’s playback to a time in seconds, the page of a video scene for example, and getPlaybackTime reads it back. The Control Audio and Video guide checks supportsPlaybackTime before it seeks.

Trim a clip to the part your users keep

setTrimOffset sets the time within a clip where its playback begins, and setTrimLength how long the clip then runs. supportsTrim tells your app whether a block can be trimmed at all.

Show a filmstrip of a video

generateVideoThumbnailSequence returns the number of frames you ask for, spread over a time range, and hands each one back as soon as it is ready, for timeline filmstrips and scrubbers. The previews render at up to 512 px per side.

FAQs

In video compression, nearly so. Encoders and streaming platforms say keyframe for the frame a player can start decoding from, which is an I-frame, and in the strict sense an IDR frame, one that no later frame reaches past. Keyframes in animation are a separate idea: a value fixed at one moment.

An IDR frame, short for instantaneous decoder refresh, is an I-frame in H.264 and later codecs after which no frame refers to anything earlier. It starts a closed GOP, so a decoder can begin there cleanly, which is why Amazon IVS wants one at the start of every segment of a live stream.

An I-frame is a complete picture, a P-frame stores what changed since earlier frames, and a B-frame can borrow from frames before and after it. In that order, each takes less data and depends on more of the frames around it.

Not if the bitrate stays the same. I-frames need more bits than P- or B-frames, so packing more of them into the same data rate leaves less for everything else, and keeping the quality means a bigger file. What more I-frames buy is a quicker start: Amazon IVS says a new live stream reaches viewers after about 3 to 4 seconds with an I-frame every second, against 6 to 7 seconds with one every 2 seconds.

A list of the I-frames in an HLS stream, which players use for trick play such as fast forward, rapid reverse and scrubbing. Each entry points at a single I-frame, set up so that a player can load and decode the entries in any order.