Video and Temporal Reasoning › Frame sampling
Language AI HandbookAll chapters Choose a frame budget based on the event durations and kinds of evidence your task needs. Regular sampling leaves gaps. Content-aware sampling moves samples toward the changes its scoring rule detects.
Think of the selection rule as a lossy transform. Regular sampling allocates coverage over time. A rule based on frame differences allocates more of its budget to changes, even when the changes reflect camera motion or lighting rather than the event.
Regular sampling and the event phase
Consider an ideal grid with one sample every seconds and an event of duration . Take the event as the half-open interval and place it away from the ends of the clip, so samples cover the adjacent grid positions. An event at least as long as the spacing always contains a sample on this grid, including at . A shorter event can fit between neighboring samples.
Now suppose the starting phase modulo is uniformly distributed. The catch probability is the fraction of phases for which some sample lies within the event interval:
The symbols are:
- : the event duration, measured in seconds.
- : the constant spacing between sample times, measured in seconds.
- : the event duration in units of the sampling spacing. Values above one are clipped to one.
For , the start phases that put the next sample inside the event occupy length out of each interval of length . At zero duration the interval is empty. At or above one sampling interval, every start phase contains a sample. This ideal calculation assumes a regular sample grid and continuous start phases. Rounding to source frame times or clipping at the ends changes the available sample times.
A 0.3-second event hits this ideal grid with probability 0.30 at a one-second spacing and 0.15 at a two-second spacing. This randomness is across event phases. For one clip and one fixed grid, the sampled frames are deterministic.
The catch probability is a simple ratio, but seeing it across a range of sampling intervals makes the blind spot concrete. The sweep below evaluates the formula on a grid of intervals for several event durations.
PythonIn [3]Expand
import numpy as np
# Catch probability P(catch) = min(Delta / s, 1) evaluated on a grid.
# Selection rule: event durations span 0.1s to 0.5s; sampling intervals
# span 0.25s to 4.0s. No randomness involved (deterministic sweep).
event_durations = np.array([0.1, 0.2, 0.3, 0.4, 0.5])
sampling_intervals = np.linspace(0.25, 4.0, 200)
# catch_prob[i, j] = probability for duration i at interval j
catch_prob = np.clip(
event_durations[:, None] / sampling_intervals[None, :], 0.0, 1.0
)VisualizationOut [4]Expand

The dashed line is a one-second sampling interval. There, event durations of 0.3 and 0.4 seconds correspond to catch probabilities of 0.30 and 0.40. A catch means that a timestamp intersects the interval. One frame may show only a small part of the action.
A detected change can also depend on whether the sample falls at the beginning, middle, or end of an action. The catch formula does not estimate recognition from those partial observations.
Repeating a query with the same sampled frames leaves the visual evidence unchanged. The answer can still vary with generation settings. To diagnose a suspected sampling miss, inspect the timestamps or rerun with a different grid.
If a discarded event left visible consequences, audio, or other traces in the retained input, a downstream model can sometimes infer it. An answer based on those traces is indirect evidence.
Uniform, dense, and adaptive sampling
Three selection strategies are useful starting points.
Uniform sampling allocates a regular time grid when sampling by timestamp. A fixed frame-index stride is equivalent only on a constant-rate sequence. Both rules can miss a short event.
Dense sampling keeps more frames within a selected interval. It improves coverage there and uses more of the frame budget, so the rest of the clip may receive fewer samples.
Adaptive sampling selects frames using a signal computed from the input. A content-change signal can respond to motion, lighting, editing cuts, or noise. Its useful target depends on the desired task.
One example is the distance between consecutive frame features. A large distance marks a change in the chosen representation. The distance alone cannot tell whether the change is relevant to the query.
The symbols are:
- : frame in the video, in temporal order
- : a mapping from a raw frame to a feature vector (a histogram, a downsampled thumbnail, or a vision-encoder embedding)
- : the frame-difference magnitude at time , i.e., the Euclidean distance between consecutive frames' feature vectors (note this requires ; is undefined)
A sampler can keep the top scores or combine a change score with periodic anchors. The same signal can miss changes when the features are insensitive to them.
A top- rule can allocate many of its slots to one dramatic event and leave another region thinly sampled. Reserving some slots for a time grid protects coverage over that grid.
Keyframe extraction and scene segmentation
Shot-boundary detection can seed keyframe selection in edited footage. A histogram or feature change can flag a possible cut. Choosing one frame per shot reduces the sequence length and can also lose actions that occur within a shot.
A continuous take can still contain useful keyframes. A sampler based only on cuts has no within-shot selection rule, so it needs another way to represent changes in that take.
Sparse "bursts" and the multi-scale compromise
Because each sampling strategy is a compromise, practical systems combine them. A common pattern is multi-scale sampling:
- Coarse pass: uniformly sample a few dozen frames across the whole video to give the model a global, low-resolution sense of the arc.
- Fine pass: once the model (or a cheap first stage) identifies a region of interest, densely sample that region to get temporal detail.
This mirrors how long-document retrieval works in Part XLIV: Retrieval-Augmented Generation: retrieve a coarse region first, then read it closely. The difference is that the "document" here is indexed by time rather than by text, and the model must learn to point at a region with timestamps.
A coarse pass can miss a small event and never request a fine pass at its location. Let event visibility guide your choice of coarse spacing and the triggers for dense resampling.
The timestamp primitive
Frame order and elapsed time are different inputs. Frame indices plus a known constant frame rate can give elapsed time. With variable frame timing, preserve the original presentation timestamps or another explicit time representation.
One way to pass elapsed time to a model is to attach a text marker to each retained frame. The example below uses hours, minutes, seconds, and milliseconds since the start of the clip:
[frame 00:00:00.500] <visual tokens for frame 17>
[frame 00:00:01.000] <visual tokens for frame 21>
...
A model can copy a displayed timestamp without computing the difference between two timestamps. For duration tasks, verify the subtraction or compute it outside the text generator using numeric times.
These markers carry elapsed time on the clip timeline. Sequence positions represent the order of retained tokens. Two neighboring frames can occupy neighboring positions even when their timestamps differ by an unusually large interval.
In the next example, the first two gaps are 33 milliseconds and the third is 167 milliseconds. Each is one frame step. The frame index alone loses the difference in elapsed time.
PythonIn [5]Expand
presentation_ms = np.array([0, 33, 66, 233], dtype=int)
print("Neighbor spacings (ms):", np.diff(presentation_ms).tolist())ConsoleOut [5]Expand
Neighbor spacings (ms): [33, 33, 167]
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!