> ## Content Index
> Fetch the complete content index at: https://ffmpeguru.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Set keyframe interval manually with -g
- URL: https://ffmpeguru.com/set-keyframe-interval-manually-with-g/
- Published: 2026-10-08T09:00:00.000Z
- Updated: 2026-10-13T17:59:50.000Z
- Author: FFmpeguru
- Tags: ffmpeg

![](https://picsum.photos/seed/ffback49/1200/630)

The keyframe interval is the distance between I-frames in the encoded video. A smaller interval improves seek performance and recovery from packet loss; a larger interval improves compression efficiency. The default is 250 frames (about 10 seconds at 25 fps), but for web video, a 2-second interval is the standard.

## The command

```
ffmpeg -i in.mp4 -c:v libx264 -crf 20 -g 60 -keyint_min 60 out.mp4
```

## What it does

The \`-g 60\` flag sets the maximum keyframe interval to 60 frames (about 2 seconds at 30 fps). The \`-keyint\_min 60\` flag sets the minimum interval to 60 frames, so the encoder cannot place a keyframe more frequently than every 2 seconds. The result is a file with a keyframe every 2 seconds, which is the standard for web video (YouTube, Vimeo, HLS). The flag also helps with seeking: a 2-second keyframe interval means a seek to any point in the file is at most 2 seconds off.

## Requirements

Any video input. The flag is an encoder option, so the encoder must support it (most do). The output is a normal MP4 with the keyframe interval set. For HLS streaming, the standard is a 2-second keyframe interval; for archival, a 10-second interval is fine.

## Things to avoid

- Setting a very small interval. A 1-frame keyframe interval (every frame is a keyframe) is the I-frame-only mode, which produces a huge file with no inter-frame compression.
- Confusing \`-g\` with \`-keyint\_min\`. \`-g\` is the maximum interval; \`-keyint\_min\` is the minimum. For a fixed 2-second interval, set both to 60 (at 30 fps).
- Forgetting that the flag is in frames, not seconds. \`-g 60\` is 60 frames, not 60 seconds. At 30 fps, that is 2 seconds; at 25 fps, it is 2.4 seconds.
- Combining \`-g\` with \`-bf\` (B-frames). B-frames reference both past and future frames, so a keyframe followed by a long B-frame chain can confuse the seek logic of some players.