Nodes/ComfyUI-vid2frames/AIA Select Video Frame
ComfyUI Node

AIA Select Video Frame

Stop eyeballing 600 stills — let this node pick the frame for you

By Pmobilee·Created 4 months ago·Updated 4 months ago· 0
AIA Select Video Frame
  • image
  • IMAGE
selector

Decode a video into a batch of frames in ComfyUI and you immediately hit a boring problem: you have hundreds of near-identical stills and you need one of them. The sharpest one to seed an img2img pass. A clean, face-free background plate to inpaint a moving subject out of. A low-motion anchor frame to feed a Wan I2V or AnimateDiff SparseCtrl start condition. Scroll the thumbnail strip long enough and your eyes cross - and "best" frame by eyeball is usually the one you picked first, not the one that actually scores best.

AIA Select Video Frame (from the tiny Pmobilee/ComfyUI-vid2frames pack) is the antidote: feed it your decoded IMAGE batch, tell it in plain text what kind of frame you want, and it hands back a single-frame batch. No API, no key, no model files to download. It's a small utility node, and it does one job quietly well.

What it actually does

The node scores every frame on four axes, all computed on CPU from the raw pixels:

  • Sharpness - variance of the Laplacian, the standard blur detector. If opencv-python is missing it falls back to a numpy gradient approximation.
  • Motion - mean pixel delta against neighboring frames, smoothed over a short window so a single jump-cut doesn't dominate.
  • Lighting fluctuation - luminance deltas between neighbors, also smoothed.
  • Faces - via MediaPipe face detection, with OpenCV's bundled Haar cascades as a silent no-download fallback if MediaPipe isn't importable.

The first and last ~8% of frames get a gentle penalty (endpoints of a shot are rarely the representative ones), with a tiny center bias as a tiebreak. Then your selector picks a weighting over those scores and it returns the winner.

The inputs that matter

There are only two inputs and one output, and you'll only touch one of them per run:

  • image - the IMAGE batch. Normally the output of a video loader/decoder node (VHS, or any load_video-style node) that gives you frames in order.
  • selector - a plain-text command. Leave it empty for "best" (sharpest, stable, moderate-motion frame), or type one of: no face, blurry, moving, static, flicker / lighting. Keyword matching is forgiving - faceless, out of focus, action, posed all work; unknown text just falls back to "best".

The neat trick is ranked picks: append rank 2 or #3 and it returns the next best-scoring frame instead of the same moment. It enforces temporal spacing, so "rank 3" gets you three genuinely different frames across the clip, not three micro-variants from the same 2-second stretch. That's exactly what you want when you're grabbing reference frames for training data or controlnet keyframes.

The output is a single-frame IMAGE batch - wire it into anything that takes an image: an img2img KSampler for the init image, Load Image-style reference inputs for I2V first-frame anchoring, or an inpaint setup for cleanup.

Install

The standard two routes, same as any custom node:

# ComfyUI Manager: search "ComfyUI-vid2frames", install, restart.
# Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Pmobilee/ComfyUI-vid2frames.git
cd ComfyUI-vid2frames
pip install -r requirements.txt

Then restart ComfyUI and the node appears under AIA/video. The only gotcha: requirements.txt pulls opencv-python and mediapipe, which are chunky installs (MediaPipe especially drags in protobuf and platform-specific wheels). It's a one-time cost, and the node degrades gracefully - no MediaPipe, no OpenCV, and it still works with pure numpy for everything except face scoring. Torch and numpy you already have; ComfyUI won't run without them.

Where people get burned

The big surprise is the rank syntax: rank 2 returns a different frame than rank 1, which is the point, but if you wanted the single best you'll be confused for a second. Also, the scoring loop runs entirely on CPU, so a 600-frame clip takes a beat to chew through - it's seconds, not minutes, but don't expect instant on a long source. And it needs a real batch: an empty image input raises a ValueError rather than silently returning nothing.

For a node with zero fanfare and zero impressions, it punches above its weight. It won't add a frame of quality to anything itself - but it'll stop you from picking the wrong anchor frame and then fighting the whole rest of the workflow for it.

CategoryAIA/video

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
selectorSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE