Nodes/PromptModels Studio/Get Frame by Index
ComfyUI Node

Get Frame by Index

Pull any single frame out of a video batch

By cdanielp·Created 9 months ago·Updated 2 months ago· 28
Get Frame by Index
  • frames
  • image
â—„index-1â–º

Video in ComfyUI is just a big image tensor - [frames, height, width, channels] - and most of the time you only want one specific moment out of that stack. GetFrameByIndex is the "any frame, not just the last one" version of the pack's GetLastFrame: you feed it a batch of frames and an index, and it hands back a single frame as a proper one-image batch. It's the node you reach for when you need frame 12 for a specific cut, or frame 0 to seed something else.

When you actually reach for it

After a video generation, the useful stills are rarely the last frame. You want the frame where the motion resolves, the midpoint of a transition, or the very first frame to loop back into a follow-up img2vid pass. Batch image workflows hit the same need - pick the Nth image out of a 20-image batch and run it through a detailer. It slots anywhere a single image is expected, and because the output keeps the batch dimension (1×H×W×C), every downstream image node accepts it without complaint.

How it works

It slices the input tensor at your chosen index, keeping the leading dimension so the result is a valid single-frame image batch. The part worth knowing is the clamping: the node won't crash on an out-of-range index. If index is bigger than the frame count it silently returns the last frame; if it's more negative than the total it returns the first. And the indexing is Python-style, so -1 means the last frame, 0 the first. That fallback behavior is friendly, but it's also a mild trap - ask for frame 999 on a 24-frame clip and you'll get frame 23, no error telling you your index is nonsense.

Inputs and output

  • frames (IMAGE) - your video frames or image batch.
  • index (INT, default -1, range −9999 to 9999) - the frame you want. Negative counts from the end; -1 is the last frame.
  • image (IMAGE) - the selected frame as a single-image batch.

Installing it

Part of COMFYUI_PROMPTMODELS (PromptModels Studio in Manager). Install once, find it under 🧩 Utility:

cd ComfyUI/custom_nodes
git clone https://github.com/cdanielp/COMFYUI_PROMPTMODELS

Restart ComfyUI. No API keys, no downloads, pure local tensor slicing.

Common issues

The only real confusion is the clamping behavior - because out-of-range indexes silently snap to the nearest valid frame, an off-by-one can look like a correct but wrong result. If a frame looks subtly "off," double-check your count. And remember this is the arbitrary-index version of GetLastFrame: for the common "just give me the end of the clip" case, the simpler sibling does the same job with one less widget to misread.

Category🧩 Utility

Inputs (2)

NameTypeDefaultDescription
framesIMAGE—
indexINT-1-9999–9999—

Outputs (1)

NameTypeDescription
imageIMAGE—