ComfyUI Node

Get Frame Range

Get Frame Range — the negative-index slicer for video batches

By gregtee2·Created 6 months ago·Updated 6 months ago· 4
Get Frame Range
  • images
  • frames
  • frame_count
start0
end0

Sometimes you don't want a whole video chunk, you want a slice of it. The last 16 frames. The first 20. Frames 50 to 70. In ComfyUI, a video is just an image batch, and this node gives you Python-style slicing on that batch with the friendly bit that matters most: negative indexing, so you can grab frames from the end without counting.

It's the range version of GetFrameByIndex in the same VideoChunkTools pack - that one returns a single frame, this one returns a batch. If you only ever need the last frame to feed forward as the next chunk's reference, use GetFrameByIndex. When you need a set of frames, this is the tool.

The inputs

  • images - your video frames / image batch.
  • start - first frame, inclusive. Negative counts from the end: -16 means "16 frames from the end".
  • end - exclusive (Python slice convention). 0 is special: it means "to the end of the video." Negative works here too, so -10 means "stop 10 frames before the end."

Two worked examples, straight from the node's own docs:

start=0,  end=16  → first 16 frames
start=-16, end=0  → last 16 frames

Both start and end are clamped to valid bounds, and end is forced to at least start + 1, so you can't hand it a range that collapses into nothing.

What you'd actually use it for

  • Crossfade inspection - pull the overlap zone out of a chunk to check whether the seam will be visible before you commit to blending.
  • Building test clips - slice the first 20 frames of a long video to iterate fast on prompts and settings without paying for a full generation.
  • Tail sampling - grab the last N frames of a chunk to see how the motion settled before you chain the next reference.
  • Extracting keyframes - pull a handful of evenly-spaced frames out of a driving video to use as FLF (first-last-frame) targets or start images.

The outputs

frames - the sliced IMAGE batch, and frame_count - an INT with how many frames came out, which is genuinely handy when you're feeding frame counts into nodes that need to know (like the WanChunkedI2VSampler's total_frames).

Installing

Same pack, same drill:

cd ComfyUI/custom_nodes
git clone https://github.com/gregtee2/ComfyUI_VideoChunkTools.git

Or search "VideoChunkTools" in ComfyUI Manager, install, restart. No dependencies beyond PyTorch - it's tensor slicing, nothing more. It'll happily slice batches from any model, not just Wan.

Honestly, this node is simple enough that you could write the slicing yourself in a tiny custom node. But you won't, and the negative indexing plus the end=0 shortcut is exactly the kind of thing you'll misremember and get wrong by one frame at 1am. Let it handle the bookkeeping.

CategoryVideoChunkTools

Inputs (3)

NameTypeDefaultDescription
imagesIMAGEImage batch / video frames
startINT0-10000–10000Start index (inclusive). Negative = from end.
endINT0-10000–10000End index (exclusive). 0 = to the end of the video. Negative = from end.

Outputs (2)

NameTypeDescription
framesIMAGE
frame_countINT