FFmpeg keyframe interval compared

Compare FFmpeg keyframe intervals from every frame to 250. A 1-second GOP cost 35 percent more bytes than the default, and it barely changed encode time.

Share

Every HLS tutorial tells you to use a 1 or 2 second keyframe interval so that segments align. Almost none of them mention what that costs.

Short version. It costs 35% of your bytes against x264’s default, and it costs essentially nothing in encode time. That makes it a pure bandwidth decision, and one most people make once and never revisit.

Keyframe interval
What does a shorter keyframe interval cost, and what does it buy?
Held constant: libx264 CRF 23 preset medium, same source, audio stripped
Bar chart. Keyframe interval. Encode time and output size for each variant, each metric scaled to its own maximum.
VariantEncodeSizeCost
-g 12 (0.4s)836 ms778.7 KB$0.0024
-g 30 (1s)939 ms584.6 KB$0.0024
-g 60 (2s)960 ms504.6 KB$0.0024
-g 250 (default)945 ms433.0 KB$0.0024
all keyframes446 ms fastest2661.4 KB$0.0039
Measured 2026-08-20 on the Rendobar API. Encode time is the FFmpeg step alone, separated from download and upload. 5 of 5 runs succeeded. Sizes are exact and repeatable. Timings are a single sample and vary up to 2x run to run, so treat small differences as noise. Why.

The size curve is steep

IntervalSizevs default
every frame (-g 1)2,661 KB+515%
0.4s (-g 12)779 KB+80%
1s (-g 30)585 KB+35%
2s (-g 60)505 KB+17%
default (-g 250)433 KB

A keyframe is a complete picture. Every other frame only stores what changed. So the interval is really a question of how often you throw away all your compression and start again, and the answer visibly compounds.

All-keyframes at 2,661 KB is 6.1x the default. That is what an intra-only encode costs, and it is why editing codecs like ProRes are enormous.

Encode time barely moved

836 ms to 960 ms across the whole practical range. That is a 15% spread against a 6x spread in output size.

And the outlier is instructive: all-keyframes was the fastest encode in the sweep at 446 ms, roughly half the default’s 945 ms. With no inter-frame prediction there is no motion estimation to do, so the encoder does far less work and produces far more bytes.

So the tradeoff is not compute against size. It is size against seek granularity, and compute is not really in the conversation.

What the shorter interval buys

Three things, and they are real:

Segment alignment. HLS and DASH segments must start on a keyframe. If your GOP is 250 frames and your target segment is 2 seconds, the packager cannot cut where you asked.

Seek accuracy. A player can only jump to a keyframe. A 250-frame GOP at 30fps means seeks land up to 8 seconds from where the user clicked, which feels broken.

Error recovery. A corrupted keyframe damages everything until the next one.

For streaming, a 2-second GOP at +17% is usually the right trade. For a download, or a file behind a player that decodes locally, the default is fine and the 35% is free money.

The number worth carrying

-g 60 at +17% against -g 30 at +35% is the same decision most people make without seeing the price. Halving the interval roughly doubles the penalty each time, and at 30fps the difference between a 1-second and a 2-second GOP is 18% of your entire bandwidth bill for a seek granularity difference almost nobody notices.

Where this stops

One 5-second 1280x720 clip, libx264 at CRF 23 preset medium, audio stripped. A short clip exaggerates the keyframe penalty slightly, because the first keyframe is a larger share of a small file. On longer content the percentages shrink but the ordering and the rough shape hold.

Content matters more than length here. High-motion footage has less inter-frame redundancy to lose, so shortening the GOP costs proportionally less. A static screencast is the worst case and will punish a short interval hardest.

Keyframe interval is one of seven settings measured on this same source. The rest are in FFmpeg encoding settings compared.

Frequently asked questions

What keyframe interval should I use for HLS?

Two seconds is usually the right trade, which we measured at 17% more bytes than x264's default. A one-second GOP costs 35% more for a seek granularity difference almost nobody notices.

How much do keyframes cost?

A great deal. Encoding every frame as a keyframe produced 2,661 KB against the default's 433 KB, 6.1x the bytes at the same quality setting.

Does a shorter keyframe interval slow down encoding?

No. Encode time barely moved across the practical range. All-keyframes was actually the fastest encode, because there is no motion estimation left to do.

Why do streaming formats need short GOPs?

HLS and DASH segments must start on a keyframe, so the GOP bounds where the packager can cut. It also bounds seek accuracy, since a player can only jump to a keyframe.

Sources

Tags #ffmpeg#x264#streaming#hls#benchmarks
All posts
Share
  1. Opus vs AAC vs MP3 vs FLAC Engineering blog
  2. AV1 vs H.264 VMAF compared Engineering blog
  3. AV1 vs VP9 vs HEVC vs H.264 Engineering blog