Image Batch Slice (C2C)
Image Batch Slice (C2C)
- images
- images
- frame_count
Image Batch Slice (C2C) is the node equivalent of Python's video[start:end:step] - and if you've ever needed to process only frames 10 through 60 of a video batch, or every second frame of a 100-frame sequence, you know the fiddly alternative: a ChainNode, a bunch of math, or loading the video three times. This just does the slice, cleanly, with Python's slice semantics you already half-know.
It's part of the C2C Helpers in ComfyUI-CustomNodePacks, the ~72-node pack from Code2Collapse (Likhith-24, active on r/comfyui). A pack this size needs a "utility drawer," and this is the frame-range drawer.
How it works
You feed it an images batch (a [B,H,W,C] tensor - a video loaded into ComfyUI is just a batch of frames) and three ints:
start- first frame, inclusive. Negative counts from the end of the batch.end- exclusive, Python-style: the slice stops before this frame.-1means "to the end of the batch", which is the default.step- stride.1keeps every frame;2keeps every second frame (frame decimation for faster testing);4keeps every fourth.
Negative values work like Python: start=-30 starts 30 frames from the end, and the node clamps everything into the valid range rather than erroring on out-of-bounds values. Outputs are the sliced images plus frame_count (INT), which is convenient for wiring into downstream logic like save filename prefixes.
It's the same idea as the pack's Frame Range Router (MEC), minus the mask routing - this one is a bare-bones batch-only slice.
The inputs and outputs that matter
images- the only required input.start/end/step- the three ints above. The two you'll actually touch:startandend. Leavestepat 1 unless you're deliberately decimating.imagesout - the sliced batch.frame_count(INT) - how many frames you got; wire it into a filename or a counter.
Installing it
Ships inside ComfyUI-CustomNodePacks, no separate repo. ComfyUI Manager → search "CustomNodePacks", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
Pure PyTorch, no extra dependencies, no models, no VRAM. The pack overall wants opencv-python>=4.7.0 and scipy>=1.10.0 for other nodes - add just those if missing (skip the full requirements.txt, which can overwrite ComfyUI's torch). Restart ComfyUI.
Common issues
- Got fewer frames than expected - check whether you meant
endinclusive. It's exclusive. Want frames 0-9? That'sstart=0, end=10. - Empty result - start at or past end, or a step that skips everything. The node clamps instead of erroring, so check
frame_counton the output. - You only want to view a range, not reshape the batch - this node genuinely slices; the pack's Video Frame Player (MEC) is the in-graph scrubber if your goal is preview instead of processing.
The honest take: it's a one-liner you could write in a custom script node - but you won't, because this exists, is already installed with the pack, and reads exactly like the Python you already know.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| start | INT | 0-100000–100000 | — |
| end | INT | -1-100000–100000 | Exclusive. -1 = end of batch. |
| step | INT | 11–1024 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| frame_count | INT | — |