Image Batch Index
Grab exactly the frames you want out of a batch
- image
- image
Most batch-slicing nodes give you a start, a step, and a count, and that's all you get. Image Batch Index is the escape hatch for when "every 3rd frame from frame 10" isn't the shape you need - you type a list of exact frame numbers and it hands back precisely those frames, in your order, including duplicates. It's the closest thing ComfyUI's batch tooling has to a "select these specific ones" command.
The index syntax
The index input is a single multiline string, and the parser is surprisingly forgiving. You can mix and match, one per line or comma-separated:
- Individual frames:
0, 3, 7 - Ranges with optional stride:
2-5or[2,5], and stepped like0-10:2(every 2nd frame from 0 to 10) - Negative indices, Python-style:
-1is the last frame,-3is third from the end - Ranges with negatives, like
-5--1for the last five - Reverse order: list them backwards and the output follows
So 0, 2, 2, 5-7, -1 gets you frame 0, 2, 2 (a duplicate - yes, it honors duplicates), 5, 6, 7, and the final frame. If you want the last three frames in reverse for a countdown, that's -1, -2, -3.
The two inputs: image (the batch) and index (that multiline string). Output: image, the extracted frames in the order you asked.
When you'd reach for it
This is the node for "I looked at a video and I want these specific 12 frames" - thumbnails, contact-sheet picks, frame-by-frame review, cherry-picking reference frames for image-to-video conditioning. It pairs with the pack's Image Batch Group, which produces start_index lists you can feed straight back in here to pull each group out. And because it honors order and duplicates, you can also use it to reorder a batch entirely - a poor man's frame shuffler.
Installing it
ComfyUI Manager, search "ComfyUI 1hewNodes", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Standard pack note: the install is fat (opencv, rembg, ultralytics, transformers...) even though this node is pure tensor indexing. Pay it once, use any of the pack's nodes.
Gotchas
Out-of-range indices are silently dropped rather than erroring - if your batch is shorter than you thought, you'll just get fewer frames and no warning, so double-check your count when the output looks short. Ranges are inclusive on both ends (unlike Python's half-open ranges), which is a pleasant surprise but worth knowing: 2-5 is four frames, not three. And remember the output preserves your order, so 5, 0 comes out as frame 5 then frame 0 - the batch is not re-sorted behind your back.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| index | STRING | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |