Nodes/ComfyUI 1hewNodes/Image Batch Range
ComfyUI Node

Image Batch Range

Slice any image batch like it's a Python list

By 1hew·Created about a year ago·Updated 7 days ago· 33
Image Batch Range
  • image
  • image
start_index0
step1
num_frame1

Once you have an image batch, you're going to want to take a slice of it - every 4th frame, frames 10 through 30, the tail of a video. That's the entire job of Image Batch Range, and it's a job worth having a dedicated node for because ComfyUI's core tooling is surprisingly thin on "give me a subset of this batch."

The name is a little misleading: it's not "range" like "a contiguous range," it's range like Python's range(). You give it a start, a step, and a count, and it walks the batch the way image[start:stop:step] would. It's a sibling of the pack's Image Batch Index (which is the free-form "grab these specific indices" node); this one is for the pattern-based slicing that shows up constantly.

The inputs

  • image - the batch to slice.
  • start_index - where to start, default 0.
  • step - take every Nth frame, default 1. This is your frame-thinning knob: step 4 on a 25fps video gives you roughly one frame every 0.16s.
  • num_frame - how many frames you want, default 1. The twist: 0 means "all remaining," which turns the node into a pure image[start::step]. Set num_frame to a positive number and it caps the output at exactly that many.

Output: a single image batch containing the selected frames, preserving order. Feed it straight into a sampler, a frame-count-sensitive video node, or a save node.

The one thing people trip on

num_frame is not an end index. If you want frames 10 through 30, that's start_index=10, step=1, num_frame=21, not num_frame=30. Get that wrong and you'll grab 30 frames past 10 instead of the window you meant. It's a small mental shift, but it's the difference between a 20-frame clip and a 30-frame one.

The num_frame=0 behavior is genuinely handy and worth internalizing: with start_index and step set, it's the cleanest way to "give me every Nth frame from here to the end" in one node. Before this existed you were wiring up arithmetic nodes or doing it by hand.

Why you'd reach for it

Thinning out a long video batch before an expensive pass is the classic use - nobody wants to run a 900-frame batch through a slow model when every 3rd frame tells the same story. It also slots into frame-count constraints: many video-model pipelines want a specific number of input frames, and this is the cheapest way to get a batch down to the exact count you need without a resample.

Installing it

ComfyUI Manager, search "ComfyUI 1hewNodes", install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart after either. Standard pack caveat: the install pulls the whole repo's dependencies (opencv, scikit-image, rembg, ultralytics and friends) even though this node is pure tensor slicing - one install bill for the entire pack.

Gotchas

Out-of-range behavior is graceful rather than loud: a start_index past the end returns an empty batch, not an error, so if a sliced workflow suddenly goes blank, check whether your indices still match the batch size after an upstream change. And negative indices aren't supported the way they are in Image Batch Index - this node is strictly 0-based and forward. For negative or scattered picks, that's the other node's job.

Category1hewNodes/batch

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
start_indexINT00–8192
stepINT11–8192
num_frameINT10–8192

Outputs (1)

NameTypeDescription
imageIMAGE