Tool

GOP Structure Visualizer: I/P/B Pattern, Keyframe Interval and Open GOP Check

Want to know how many seconds apart the keyframes in your video are, how many B-frames come in a row, and whether it is safe to cut at a keyframe? Paste the frame info you extracted with ffprobe, and the tool draws the I/P/B pattern and calculates the GOP length and clues for an open GOP. Your input is processed only inside this browser.

The first 30 seconds or so is enough. Output from this command is read most accurately.

ffprobe command

ffprobe -v error -select_streams v:0 -read_intervals "%+30" -show_entries frame=pict_type,key_frame,pts_time,pkt_dts_time -of compact input.mp4

The examples are made-up data for illustration, not values from a real file. The default -show_frames output ([FRAME] blocks) is also supported.

How do you read it?

  • I, P and B: an I-frame can be reconstructed on its own without other frames, a P-frame references earlier frames, and a B-frame can reference frames both before and after it. The principles are covered in the GOP structure lesson and the intra prediction lesson.
  • Display order: ffprobe’s -show_frames is known to output decoded frames in the order they appear on screen. So even if the pattern looks like IBBPBBP, the storage and decoding order inside the file is different: I P B B P B B. The pattern in this tool is the display order, re-sorted by pts.
  • GOP length: the number of frames from a keyframe (key_frame=1) to just before the next keyframe. The last GOP in the pasted stretch may be cut off, so it is left out of the length distribution.
  • Keyframe interval (s): the difference between keyframe pts values. For a video encoded with a fixed interval, the distribution clusters around one or two values; for a video that inserts a keyframe at every scene change, the lengths are uneven.

How does it tell whether a GOP is open?

An open GOP is known as a structure in which the B-frames after a keyframe produce pictures from before the keyframe and so reference the previous GOP. In display order it looks exactly like a closed GOP, I B B P, so you cannot tell them apart from the pattern alone. The tool therefore puts the frames in decoding-time (dts) order and counts frames that are decoded after a keyframe but whose display time (pts) is earlier than the keyframe. If there is even one, it is marked as an open GOP; if there are none at any of the keyframes checked, it is marked as a closed GOP.

InputVerdict
No B-frames at allNo distinction needed
Many lines are missing dts, pts or key_frame (more than 10% of frames)On hold
Fewer than 2 keyframes to checkOn hold
At least 1 keyframe has leading picturesLooks like an open GOP
NoneLooks like a closed GOP

These thresholds and this method are rules set by this site and have not been verified against many real files. It can only speak for the stretch you included, so there is no guarantee that the whole video has the same structure.

How to use it

  1. Extract the first 30 seconds with the ffprobe command above the tool and paste it. -read_intervals "%+30" sets the range. If the video has frequent scene changes, move the range to a part with motion.
  2. Cutting: if you cut without re-encoding, the start can be pulled back to the previous keyframe. From the keyframe times alone, the tool calculates the average and maximum pull-back. Plan the exact times in the keyframe cut planner, and when you join several pieces, use the concat compatibility checker.
  3. Preparing for streaming: course chapter 10 explains that adaptive streaming needs closed GOPs and fixed-interval keyframes at segment boundaries. If the tool reports an open GOP or uneven intervals, it can build a command that re-encodes with a target interval.
  4. Getting a feel for file size: the tool matches the median GOP length to the closest of the keyint values we tested in our measurements (12, 50 and 250) and shows the range of size differences. The source and limits of those numbers are in the keyint and B-frame measurements.

Limitations

  • The open-GOP verdict depends on the display and decoding times and the key_frame flag that ffprobe prints. It was not verified on real files, and field names and values may differ between ffprobe versions. If a field is missing, the result is “on hold.”
  • For HEVC, there is a dispute that ffprobe’s classification of I-frames and keyframes looks different from the actual bitstream structure. We could not confirm how forms such as HEVC CRA are reported, so treat the result as a rough guide. For the exact structure, you need to look at the NAL unit types directly with a bitstream analyzer.
  • With pict_type, you cannot tell whether a B-frame is one that other frames reference (a B-pyramid), and the slice types defined by the codec specification may not map one-to-one to frame types. Keep in mind that this tool only counts the length of B runs.
  • Even when key_frame is 1, there is no guarantee that the point can be seeked freely in every player. Actual seek time was not measured, and the cut offset is arithmetic on keyframe times.
  • The keyint comparison comes from 4 clips of 10 seconds each, at 1080p 25 fps, 8-bit, with one preset (medium), measured on one PC. It cannot be carried over as is to other videos.
  • The generated commands are starting examples. The effects of CRF, preset and scenecut=0 were not measured, and the x265 open-gop default follows what is known.
  • The text you enter is never sent to a server.