#[non_exhaustive]pub enum Sampling {
All,
EveryNth(u64),
EverySec(f64),
KeyframesOnly,
UniformN(u32),
}Expand description
How to select which decoded frames are exported.
Index-based modes (All, EveryNth) count delivered decoder output;
time-based modes (EverySec) float their grid on the first delivered frame
and compare presentation timestamps.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
All
Every decoded frame (the default).
EveryNth(u64)
Every n-th decoded frame, starting with the first (n >= 1).
EverySec(f64)
Starting from the first delivered frame, the first frame at or after each
subsequent k * seconds boundary (k = 1, 2, …). No synthesis: sparse
sources yield fewer frames, and each source frame is selected at most once.
KeyframesOnly
Only frames flagged as keyframes. Pins the decoder option
skip_frame=nokey for a decode-time fast path, plus a key-flag check as a
belt for codecs that ignore the hint.
UniformN(u32)
Exactly n frames (fewer only when a lower max_frames cap wins),
sampled uniformly by presentation time over the (trimmed) duration —
the standard VLM/CLIP primitive. Short inputs pad by repeating the
nearest displayed frame; each repeat keeps that frame’s pts_us.
Requires a resolvable duration (see duration_hint_us).
Cost model: the strategy is a single sequential decode of the (trimmed)
input — there is no seek-per-target fast path. Frames that lose the
grid race are dropped pre-filtergraph and pay no scaling, but once the
grid completes the remaining tail (~1/(2n) of the span) passes
through the graph — and is scaled — solely to keep the encoder-side
termination path fed.