Get Effing Last Index Number
The frame-count node named for how you feel
- images
- last_index
- count
The name says it all, honestly. Every video workflow reaches the moment where you need to know how many frames are in a batch and what the last one's index is, and it's never convenient to find out. Get Effing Last Index Number takes an IMAGE batch and reports exactly two things: last_index (count minus one, or 0 for empty) and count (the number of frames).
It's the emotional cousin of the frame adjusters in this same pack (Wan 2.1 Frame Adjuster, MiniH3 Magic) - video models have strict frame-count requirements, and the first step of satisfying them is knowing what you've got. This node is that first step, without you squinting at a batch-size widget or counting frames in a preview.
How it works
One required input, images (an IMAGE batch). Two INT outputs:
last_index- zero-based index of the last frame (count - 1, or 0 for an empty batch)count- total number of frames
There is no optional input, no mode toggle. It reads the tensor's batch dimension and does the subtraction. That's the entire mechanism, and that's fine - the value is in having it in the graph, feeding other nodes, instead of transcribed from a console log.
Why the index matters more than the count
ComfyUI's frame-indexing convention bites everyone once: a batch of 50 frames is indexed 0 through 49, so the "last frame" is 49, not 50. Feed count where an index is expected and you're off by one - and off-by-one in a video pipeline means a missing or duplicated frame somewhere you'll chase for an hour. last_index exists precisely so you grab the right number.
Real uses:
- Wire
countinto a frame adjuster's target so it can pad up to the model's required length. - Wire
last_indexinto a "grab last frame" or loop-boundary node to know where the batch actually ends. - Gate a conditional on whether the batch is empty (
countof 0) before running a save or export.
Where it sits in the pack
The "Effing" in the name is pure TrentNodes personality - the author's naming runs from Cowboys to Ho Downs, and the category is Trent/Utils, alongside Round Up and friends. It pairs naturally with the pack's Grab First Frame, Cherry Pick Frames, and the animation timing nodes, which all care about batch geometry.
One honest caveat: it reports the batch frame count of whatever IMAGE tensor you hand it. If you're working with a latent batch or an un-decoded video, this isn't the node - feed it decoded frames. Also, empty batches report last_index as 0, so don't treat "0" as proof a frame exists; check count too if emptiness is a real possibility.
Install
One of ~69 nodes in TrentNodes:
# ComfyUI Manager: search "Trent Nodes"
# or:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes && pip install -r requirements.txt
No dependencies, no models, no downloads. It's a tiny utility that earns its place the way most tiny utilities do - you'll use it constantly once it's there, and curse the days before you had it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| last_index | INT | Zero-based index of the last frame (count - 1, or 0 for empty) |
| count | INT | Number of frames in the batch |