---
title: "What Is an I-Frame in Video? Keyframes, GOPs and IDR - CE.SDK Glossary"
description: "An I-frame is a video frame stored whole, where decoding can start. Map the I-frames in your own MP4 and see how GOPs and IDR frames change seeking and cuts."
url: "https://img.ly/glossary/i-frame/"
type: "page"
---

> This is the markdown version of [What Is an I-Frame in Video? Keyframes, GOPs and IDR - CE.SDK Glossary](https://img.ly/glossary/i-frame/). For all pages in one file, see [llms-full.txt](https://img.ly/llms-full.txt). For an index of all available pages, see [llms.txt](https://img.ly/llms.txt).

---

# 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](https://img.ly/glossary/video-compression.md), the I-frames a player can start from are also called keyframes, which is a different idea from the [keyframes of an animation](https://img.ly/glossary/keyframe.md). 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](https://img.ly/glossary/h264.md) 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](https://img.ly/glossary/mp4-vs-mov.md) 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.

## 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**

```bash
# 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.

- **Live streaming**: I-frame spacing: 2 seconds, How to set it up: A fixed keyframe interval, at most 4 seconds for YouTube Live

- **YouTube upload**: I-frame spacing: Half a second, How to set it up: A closed GOP of half the frame rate, 15 frames at 30 fps

- **HLS or DASH stream**: I-frame spacing: At least one per segment, How to set it up: Closed GOPs, each segment starting on an IDR frame

- **Editing master**: I-frame spacing: Every frame, How to set it up: An intra-only codec such as ProRes

- **Cut without re-encoding**: I-frame spacing: At each cut, How to set it up: 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](https://img.ly/products/video-sdk.md) 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](https://img.ly/glossary/timeline.md) filmstrips and scrubbers. The previews render at up to 512 px per side.

## FAQs

### I-Frames

**Q: Are I-frames and keyframes the same thing?**

A: 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.

**Q: What is an IDR frame?**

A: 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.

**Q: What is the difference between I, P and B frames?**

A: 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.

**Q: Do more I-frames make a video look better?**

A: 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.

**Q: What is an I-frame playlist?**

A: 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.

## Links

- [Video Editor SDK](https://img.ly/products/video-sdk.md): Your users scrub through footage, trim each clip on a timeline and export the finished video.
- [Control Audio and Video](https://img.ly/docs/cesdk/js/create-video/control-daba54.md): Play, pause and seek video in code, with the playback time in seconds.
- [Thumbnail Previews](https://img.ly/docs/cesdk/js/export-save-publish/thumbnail-previews-dcf031.md): Build timeline filmstrips and scrubbers from frames spread over a time range.

---

## More Resources

- **[IMG.LY Website](https://img.ly/index.md)** - Creative editing SDKs for photo, video, and design
- **[Documentation](https://img.ly/docs/cesdk/)** - CE.SDK developer documentation
- **[Build with a coding agent](https://img.ly/SKILL.md)** - A skill that adds a CE.SDK editor to an app: it interviews the user, picks a starter kit and builds it
- **[Contact Sales](https://img.ly/forms/contact-sales.md)** - Get a custom quote. A public JSON API accepts the request directly, no account or key needed. Ask your user for consent and their details first.
- **[Free Trial](https://img.ly/pricing.md)** - Start building with CE.SDK
