Nodes/Various ComfyUI Nodes by Type/Extract Image Sequence From Batch
ComfyUI Node

Extract Image Sequence From Batch

Slice a range of frames out of a batch

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Extract Image Sequence From Batch
  • images
  • IMAGE
i_start0
i_stop0
inclusivefalse

You've got a batch of images - say 64 video frames - and you only want frames 10 through 30. This node does exactly that: it takes a batch and gives you back a slice of it, defined by a start index and a stop index. If you've written any Python, it's images[i_start:i_stop]. If you haven't, think of it as "cut out frames X to Y and throw away the rest."

It's a video and animation workhorse. Frame batches get big and unwieldy, and often you only care about a stretch in the middle - trimming a clip down to the good part, isolating a section to re-process at higher quality, or chopping a long sequence into chunks that fit in VRAM. This is also the pack's most-clicked node by a wide margin, which tells you people go looking for exactly this operation and don't find a clean built-in for it.

How it works

Standard array slicing on the batch dimension. It keeps the frames from i_start up to i_stop and drops everything outside that window. The inclusive toggle decides whether the stop frame itself is kept.

Inputs and outputs

  • images - the batch to slice.
  • i_start - the first frame to keep, zero-indexed. Frame 0 is the very first image.
  • i_stop - where to stop.
  • inclusive - false (default) means the stop index is excluded (Python-style: i_start up to but not including i_stop). Set it true if you want the stop frame kept too. This is the setting people misread most, so decide it on purpose.

Output is the sliced IMAGE batch.

Installing it

This node is in the pack's comfyui_image_sequence file. Install via ComfyUI Manager (search Various ComfyUI Nodes by Type / comfyui-various) or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various

Restart ComfyUI. No models, no extra pip dependencies.

Common issues

The number-one gotcha is the indexing convention. It's zero-based, and by default the stop index is exclusive - so i_start=0, i_stop=16, inclusive=false gives you sixteen frames (0 through 15), not seventeen. If you're getting one more or one fewer frame than you expected, that's the inclusive flag talking.

The other thing to watch is asking for frames that don't exist. If you set a stop index past the end of the batch, you're relying on the slice to just stop at the real end. The clean way to avoid surprises is to feed it real numbers: run JWImageBatchCount on the batch first to learn how many frames you actually have, then do your index math against that count instead of guessing. That keeps the slice honest even when the input length changes between runs.

And if the node loads red as missing in a downloaded workflow, the pack just isn't installed - Manager's "Install Missing Custom Nodes" or a clone of the repo above sorts it out.

CategoryjamesWalker55

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
i_startINT0
i_stopINT0
inclusiveCOMBOfalse2 options: false, true

Outputs (1)

NameTypeDescription
IMAGEIMAGE