Loop Calculator
The tiny node that does your loop math so you don't have to
- images
- total_loops
Here's the workflow: you're extending a video loop in ComfyUI - sampling a few more frames of context, feeding them back, repeating until the clip reaches the length you want. The number of passes depends on three things: how many frames you need total, how many frames each loop context covers, and how many of those frames overlap with the previous pass. That is a one-line formula, and Loop Calculator is the one-line formula as a node.
It's deliberately boring. You tell it total_frames (your target clip length), context_length (frames per loop iteration, default 8), and overlap_frames (how many frames carry over, default 4). Plug in the image batch you're actually looping over, and it returns total_loops - the number of iterations you need. It even looks at the batch size of your images input and subtracts it, so if you've already generated the first chunk of frames, it only counts what's still missing.
The mechanism, quickly
The math is the standard stride calculation: every loop after the first advances by context_length β overlap_frames frames (the effective_stride), so total_loops = ceil(remaining_frames / stride), with a floor of 1 so a degenerate workflow still gets one pass. Nothing clever, nothing hidden - which is the point. You're not here for the node, you're here to stop doing this in your head every time you tweak a resolution.
The inputs that matter
total_frames- the number of frames in your target video. If it's a video, this is your frame count; if it's an audio-synced loop, the audio version of this node (Loop Calculator (Audio)) will hand you the equivalent number.context_lengthandoverlap_frames- must match what your sampler context is actually doing, or the loop count is right on its own terms and wrong in your workflow. This is the one thing that burns people, every time.images- the current frame batch. It only uses the batch count, so you can also leave it unconnected and it just treats your total as "everything still needs generating."
One output, total_loops (INT), usually feeding the loop/iteration control on your sampling feedback loop or a counter node.
Where it fits
It's the frame-counting half of the loop toolkit in Eclipse > Video. Its sibling Loop Calculator (Audio) answers the same question when your length is defined by an audio track, and Loop Align Silence tells you where the transitions should land. In the author's own workflow conventions (see the tooltips that reference motion_frame_count and Smart Folder context), the defaults of 8/4 here versus 81/9 in the audio version just reflect different frame-budget scales - set them from your actual workflow, not the other way around.
Install
Part of ComfyUI_Eclipse, r-vage's big utility pack (successor to RvTools_v2). Easiest via ComfyUI Manager - search ComfyUI_Eclipse - or:
cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI_Eclipse
Restart ComfyUI. No model downloads, no heavy deps beyond what ComfyUI already ships; the pack's requirements.txt (opencv-python, aiohttp, etc.) only matters if a node errors on import. One warning for workflow shoppers: the pack's v4.0 dropped all legacy node IDs, so a pre-v4 shared workflow that won't load usually wants the built-in Workflow Migration Tool, not a manual reinstall.
Common issues
The only real failure mode is a mismatch: loop count that never matches your sampler's output length means context_length or overlap_frames here disagrees with the sampler settings downstream. If total_loops feels one too high, remember the minimum of 1 - a short clip still counts as one pass. That's it. This node is the rare plumbing node that's hard to get wrong, because it doesn't do anything except add, subtract, and round up.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| total_frames | INT | 161β10000 | Total number of frames in the video. |
| context_length | INT | 81β32 | Context length for frame calculation. |
| overlap_frames | INT | 40β32 | Number of overlapping frames between contexts. |
| images | IMAGE | Batch of images to process. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| total_loops | INT | β |