ComfyUI Node

Batch Slice

Cut a contiguous slice out of a frame batch, Python style

By r-vage·Created 10 months ago·Updated a day ago· 31
Batch Slice
  • image
  • image
  • count
start0
end0

Batch Slice returns a contiguous sub-range of an image batch - a slice of the frames, not a crop of each image. You give it a start and an end, and you get back only those frames, plus a count. It's the frame-level equivalent of trimming a video, and if you've ever needed to drop the first ten garbage frames off a generation run, you know why it exists.

The semantics that matter (read this twice)

The start/end inputs follow Python slice semantics, which are not what people first guess:

  • 0-based. start=0 is the first frame.
  • Negative numbers count from the end. start=-1 is the last frame, -2 the second-to-last, and so on.
  • end=0 means "to the last frame inclusive." Not "zero frames." This is the trap: if you want frames 5 through the end, you set end=0, not end=-1.
  • Both indices are inclusive. Python's list[5:10] gives you indices 5–9; here start=5, end=10 gives you frames 5 through 10.

The node resolves negatives safely (clamping to valid bounds) and, if you somehow set start > end, it logs a warning and swaps them rather than returning an empty batch - a forgiving touch that will save you a confused run.

Inputs and output

  • image - the [B,H,W,C] batch to slice.
  • start - first frame to include. 0 = first frame; negatives from the end.
  • end - last frame to include (inclusive). 0 = last frame; negatives from the end.
  • Outputs - image (the sliced batch) and count (how many frames you got).

Typical uses

  • Trimming. Drop the first N frames of a batch that started before the sampler settled: start=10, end=0.
  • Keeping the tail. Only the last 16 frames of a 120-frame run: start=-16, end=0.
  • Extracting a clip. Frames 30 through 60 of an animation pass: start=30, end=60.

The count output is genuinely useful when you're feeding a video save node or a loop calculator that needs to know the exact frame count after the trim.

Installing it

Part of ComfyUI_Eclipse, installed once:

cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI_Eclipse

Restart ComfyUI (or ComfyUI Manager → search "ComfyUI Eclipse"). Depends on torch, which ComfyUI already provides.

Gotchas

Pack-wide: ComfyUI_Eclipse was formerly RvTools, and v4.0.0 removed all legacy nodes - old workflows need the Workflow Migration Tool node (or python tools/migrate_workflow.py <workflow.json>) to rewrite old IDs with a backup. And re-read that end=0 rule before your first run - "end 0 means the end" is the one thing users get wrong, and it's the difference between a clean trim and an empty batch.

Category🌒 Eclipse/ Image/Batch Operations

Inputs (3)

NameTypeDefaultDescription
imageIMAGEImage batch [B,H,W,C].
startINT0-99999–99999First frame to include. 0 = first frame. Negative values count from the end (-1 = last frame).
endINT0-99999–99999Last frame to include (inclusive). 0 = last frame. Negative values count from the end.

Outputs (2)

NameTypeDescription
imageIMAGE
countINT