Topic 3 of 5 · 4 min read
Frame sampling rates and what they miss
Goal: Pick a frame sampling strategy for a given video task and name the events the chosen rate would miss.
A model does not watch a video. It sees a list of still frames taken at a chosen rate, so any event shorter than the gap between frames can be missed entirely. Choose the rate from the shortest event you care about.
Check yourself · 1 of 3
A model samples a video at one frame per second. A warning dialog is on screen for 0.4 seconds. What is the likely result?
Why it matters
Gemini's documentation says video is processed by default at one frame per second, with audio alongside. A one-second gap is fine for a lecture. It is not fine for a goal in a football match, a flash of an error dialog, a license plate passing at speed, or a quick click in a screen recording. The model will not tell you it missed the event. It will describe the frames it has and may fill the gaps with a plausible story.
How to choose
- Name the shortest event that matters. A slide change lasts minutes. A button flash may last 200 ms.
- Sample at least twice as fast as that event. For a 200 ms flash you need five or more frames per second, over that span only.
- Spend frames where they pay. Use a low rate for the whole video and a high rate for a clipped span. Gemini lets you set
start_offsetandend_offsetto clip, and a customfpsvalue, and it bills only the clipped interval. - Sample at changes, not on a clock. A scene-change detector such as PySceneDetect, or ffmpeg's scene filter, picks a frame when the picture changes. A screen recording with long pauses then gives far fewer frames than a fixed rate, yet catches every new screen.
- Prefer sharp frames. Video compression stores full keyframes now and then and small changes in between. Extracting keyframes avoids blurry frames from the middle of motion.
An ffmpeg command that keeps frames where the scene changes by more than 30 percent:
ffmpeg -i demo.mp4 -vf "select='gt(scene,0.3)',showinfo" -vsync vfr frames/%04d.jpg
Before and after
Before: A 40-minute screen recording is sent at the default rate to find when an error toast appeared. The toast is visible for 0.8 seconds. The model reports no error.
After: The transcript is searched first and points to 21:00 to 22:00. That minute is clipped and sampled at 5 frames per second. The toast appears on three frames, and the model reports it at 21:34.
What goes wrong
- Silent misses. The answer "nothing happened" can mean "nothing in the frames I got".
- Clock sampling on static footage. A fixed rate sends hundreds of near-identical frames and pays for each.
- Scene detection on gradual changes. A slow fade or a slideshow with the same background may never cross your threshold.
- Raising the rate for the whole video. It multiplies cost for minutes that do not matter. Clip first.
Examples
Which rate for which task
| Task | Shortest event | Strategy |
|---|---|---|
| Summarize a lecture | a slide, minutes | default 1 fps |
| Find an error toast in a screen recording | about 1 second | scene-change frames, then 5 fps on a clip |
| Read a number plate | a few frames | keyframes from the 10-second clip, 10 fps |
Clipping with a higher rate
video_part = {
"type": "video",
"uri": uploaded.uri,
"processing": {"start_offset": "1260s", "end_offset": "1320s", "fps": 5},
}
One minute at 5 fps is 300 frames. The same rate over the whole 40-minute file would be 12,000 frames. The field names follow the current Gemini docs; check them for your SDK version.
Key points
- The model sees frames, not motion: an event shorter than the gap between sampled frames can vanish without any warning.
- Gemini's default is one frame per second, so choose a higher rate only for the span where short events matter.
- Set the rate from the shortest event you care about and sample at least twice as often as it lasts.
- Scene-change sampling follows the content, which suits screen recordings and slides better than a fixed clock.
- Clip to the relevant span first, using a transcript or a coarse pass to find it, and raise the rate only there.
Common mistakes
- Treating "the model saw nothing" as proof that nothing happened, when the event may have fallen between two frames.
- Raising the frame rate for the whole video instead of clipping to the span that matters.
- Using a fixed rate on a screen recording or slideshow, which pays for hundreds of identical frames.
- Setting a scene-change threshold once and never checking it on slow fades or similar-looking slides.
Check yourself · 2 of 3
You must find a 1-second flash in a 30-minute recording at reasonable cost. What is the best plan?
Check yourself · 3 of 3
A screen recording has long pauses and then a new screen appears. Which sampling suits it?
Practice items, not counted towards your mastery.
Start here
- Video understanding (Gemini API docs) (opens in a new tab)DocsFree
Official guide to video input, MM:SS timestamps, clipping, custom frame rates and per-second token counts.
- Files API (Gemini API docs) (opens in a new tab)DocsFree
How to upload large media once, wait for processing and reuse the file reference across requests.
- Understand and count tokens (Gemini API) (opens in a new tab)DocsFree
Lists token rates for video and audio and shows how to count tokens before sending a request.
More for this topic
- PySceneDetect (opens in a new tab)ToolFree
Open-source scene-cut detector you can use to pick frames and split a video at real changes.