Nodes/ComfyUI-PainterNodes/Painter Frame Extractor
ComfyUI Node

Painter Frame Extractor

Pull two frames out of any video batch

By princepainter·Created 7 months ago·Updated 5 days ago· 194
Painter Frame Extractor
  • image
  • start_image
  • end_image
  • image1
  • image2
  • image1_idx
  • image2_idx
image1_idx0
image2_idx0

In ComfyUI, a video isn't a video - it's an IMAGE tensor where the first dimension is frames. That's fine until you need "the frame at 3 seconds" and find yourself fumbling with indexing math. PainterFrameExtractor is the node that pulls exactly the two frames you want out of an image sequence, and as a bonus hands you the first and last frame of the batch. If you've ever needed a start frame and an end frame for an FLF or loop workflow, this is the clean way to get them.

What it is

A small image/batch utility. You feed it an IMAGE (a video clip or image batch) and two indices, image1_idx and image2_idx, and it returns six outputs:

  • start_image - the first frame of the batch
  • end_image - the last frame of the batch
  • image1 / image2 - the frames at your chosen indices
  • image1_idx / image2_idx - the indices echoed back

The index echoes are the quietly useful part: wire them forward into nodes that need to know where a frame came from, so downstream conditioning stays in sync with what you actually extracted.

How it works

The mechanism is reassuringly boring. It looks up the frame count, clamps both indices into range (max(0, min(idx, total-1))), and slices single frames out. Clamping means an out-of-range index doesn't crash - you just get the last frame instead of an error, which is the good kind of forgiving. Negative indices aren't treated as "from the end," so remember 0 is the first frame and indexing starts at zero like the rest of ComfyUI.

Where you'd use it

The obvious pattern is FLF and loop work: feed a rendered clip or an existing video in, grab start_image and end_image, and drop them into an FLF2V-style builder to re-generate between them. The other common pattern is chaining - take frame 0 and frame 80 of a sequence you like and reuse them as anchors for a longer, re-diffused take. If you mostly want the two ends, this node gives them to you without touching the middle.

Install

Ships in the PainterNodes pack. ComfyUI Manager → search "PainterNodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/princepainter/ComfyUI-PainterNodes
cd ComfyUI-PainterNodes
pip install -r requirements.txt

Dependencies are just soundfile and numpy; the pack never downloads models by itself.

Common issues

  • "Wrong" frame returned - check the index bases. ComfyUI is zero-indexed, and this node clamps rather than errors, so an index past the end silently returns the last frame. If you meant "frame at 3 seconds" you still need to convert seconds × fps yourself.
  • Indexes that should count from the end - there's no negative-index support here. If you need the second-to-last frame, use the end_image output or compute the index externally.

It's a tiny node, and it won't change your life. But when you're three nodes deep into a video graph and need the two ends of a clip as clean images, it's the difference between a wire and a headache.

Categoryimage/batch

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
image1_idxINT00–99999
image2_idxINT00–99999

Outputs (6)

NameTypeDescription
start_imageIMAGE
end_imageIMAGE
image1IMAGE
image2IMAGE
image1_idxINT
image2_idxINT