Nodes/ComfyUI/Sample Video Frame
ComfyUI Node Runs on cloud

Sample Video Frame

Cut any video down to exactly N frames

By Comfy-Org·Created 4 years ago·Updated about 5 hours ago· 128,055
Sample Video Frame
  • video
  • video
num_frames16
strategyuniform
seed0

Video models are picky about frame counts. Wan runs 81 frames out of the box, LTX generations traditionally sat around 121, and most training pipelines want a fixed length so every clip in the batch has the same shape. Your source footage, meanwhile, is 2 seconds here and 9 seconds there. Sample Video Frame is the node that reconciles the two: feed it any VIDEO and it hands back a VIDEO with exactly the frame count you asked for, one of four strategies deciding which frames survive.

It's a core node from the mid-2026 video-dataset work, still experimental, and it sits at the natural choke point of any video graph: after a loader, before an encoder. Load a clip, cut it to your model's native frame count, then encode to latents - whether you're assembling training data with the dataset nodes or prepping an image-to-video input.

How it works

The node reads the clip's frame count and frame rate, then clamps num_frames to the video's actual length - ask for 100 frames from a 50-frame clip and you get 50, no error, no padding. Then the strategy takes over:

  • uniform (default) - picks frames evenly spaced across the whole clip. Ask for 1 and you get the middle frame.
  • head / tail - first or last N. Both are fully lazy: ComfyUI trims the reference without decoding a single frame.
  • random - N distinct frames at random, but kept in chronological order, so you never get a scrambled clip back.

There's a second lazy trick hiding in uniform and random: the node opens the container once and decodes only the frame indices it actually wants, not the whole file. On a long clip that's the difference between reading a few megabytes and reading everything.

Inputs and outputs

  • video - anything that produces a VIDEO: Load Video, a folder loader, or another transform.
  • num_frames - default 16, range 1–9999. Set it to your model's native count.
  • strategy - uniform / head / tail / random, default uniform.
  • seed - only consulted when strategy is random. It's a no-op otherwise, which trips people up when they bump it and see nothing change.

Output is a single video, same frame rate as the input.

Gotchas

  • It samples; it doesn't interpolate. Uniform pulls real frames and drops the rest, so motion gets strobier than the original at the same fps. If you want smooth slow-motion or invented in-between frames, that's Frame Interpolate's job - this node is for length normalization, not quality upsampling.
  • num_frames is a cap, not a promise. A short clip yields fewer frames, and a downstream node that assumed exactly N may complain.
  • The output order is always chronological. random randomizes which frames are kept, never their order - handy for training diversity, useless for "shuffle the clip."
  • For arbitrary contiguous ranges - not just head/tail - look at the sibling temporal crop nodes in the same family; they're the general case of this.
Categoryvideo

Inputs (4)

NameTypeDefaultDescription
videoVIDEOInput video.
num_framesINT161–9999Number of frames to sample.
strategyCOMBOuniformuniform: evenly spaced, head: first N, tail: last N, random: random sorted.
seedINT00–18446744073709550000Random seed (only used with 'random' strategy).

Outputs (1)

NameTypeDescription
videoVIDEOSampled video.