Sampling Methods
Sampling Methods
Designed for advanced use cases, sampling_method offers fine‑grained control over frame selection before AI processing - eliminating extra coding or manual editing.
Optimized frame refinement reduces data load, speeds up processing, and delivers more accurate results across a wide range of scenarios.
Available options: "duration", "middle", "random", "fps".
| Method | Description | Benefits | Compatible Parameters |
|---|---|---|---|
| "duration" (default) | Selects frames based on video length in seconds, spaced evenly across the timeline. Frame count is limited by min_num_frames and max_num_frames. - If video duration (in seconds) < min_num_frames → sampled frames = min_num_frames - If video duration (in seconds) > max_num_frames → sampled frames = max_num_frames - For very short videos (e.g., 1 second long), the number of sampled frames is calculated from the video’s FPS and adjusted to the nearest lower multiple of 8. For example: a 1‑second video at 30 FPS will be sampled 24 frames. |
Automatically scales the frame selection to match longer or shorter videos, while respecting defined limits. | min_num_frames, max_num_frames |
| "fps" | Selects frames at a fixed rate (frames per second), evenly spaced through the video. | Ensures consistent time-based sampling across different video lengths. | sampling_fps, max_num_frames |
| "middle" | Divides the video into evenly spaced intervals based on max_num_frames and selects the middle frame from each interval. If the video contains fewer frames than max_num_frames, the last frame is repeated until the limit is reached. |
Keeps evenly distributed frames while prioritizing the center of each segment, useful when key content appears mid‑scene. | max_num_frames — The default min_num_frames is 64; set it lower than max_num_frames for proper sampling. |
| "random" | Similar to "middle", but instead of selecting the middle frame from each interval, it selects a random frame within each interval. | Adds variety to frame selection, increasing coverage of diverse video content. | max_num_frames. The default min_num_frames is 64, please change to lower number than max_num_frames |
Important Notes
- Processing time increases with the number of frames. Select an appropriate sampling strategy,
min_num_frames,max_num_frames, and input video length to balance speed and output quality.