Loop Image Sequence
Fit a frame batch to an exact length
- images
- IMAGE
JWLoopImageSequence takes a batch of frames and loops it to hit an exact target frame count. If you've got 10 frames and ask for 16, it wraps back around and keeps pulling frames from the start until it has 16. Ask for fewer than you have and it trims. Either way you come out with precisely the number you specified.
This is a video-workflow convenience node. Models and nodes in the animation world are picky about frame counts - a video pipeline might want exactly 16 or 24 frames, an AnimateDiff context window has a length, and a mismatched batch either errors or produces something ragged. Rather than manually duplicating or cutting frames to match, you drop this in and pin the count. It's also the easy way to make a short clip loop: feed a handful of frames, set the target higher, and the sequence cycles cleanly back to the beginning.
What it actually does
It loops the input batch to reach target_frames. Because it wraps from the end back to the start, the tail of the output flows into the beginning of the source - which is exactly the property you want for a seamless loop, provided your source was designed to loop in the first place. If the target is smaller than the input, it just takes the first target_frames. The frames themselves aren't interpolated or blended; it's repetition and truncation, not motion synthesis.
The inputs and outputs that matter
images(IMAGE) - the batch of frames to loop or trim.target_frames(INT, default 16, step 1) - how many frames you want out. More than the input loops; fewer trims.
Output is a single IMAGE batch of exactly target_frames frames. Wire it into whatever consumes a frame stack - a video encoder, an AnimateDiff sampler, a save-sequence node.
How to install it
Pack: jamesWalker55/comfyui-various. ComfyUI Manager - search Various ComfyUI Nodes by Type, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various
then restart. No dependencies. This node lives in comfyui_image_sequence.py with the pack's other sequence tools (batch load, save, extract), so if you only need the sequence utilities you can drop that single file into custom_nodes/ per the author's recommendation.
Common issues & troubleshooting
Looping repeats frames; it doesn't invent motion. If your source is 10 frames and you loop to 60, you get the same 10 frames six times over - not smooth new in-between motion. For genuine frame interpolation (creating new intermediate frames) you want a dedicated interpolation node like an RIFE/FILM-based one, not this. JWLoopImageSequence is about counts, not smoothness.
A visible jump at the loop point. The wrap goes straight from your last frame back to your first. If those two frames don't match, you'll see a hitch every cycle. Clean loops require source footage that was shot or generated to loop; this node can't hide a hard cut.
Off-by-one expectations. Set target_frames to the exact number your downstream model wants. If a video node still complains about length, double-check what count it actually expects (context length vs. total frames aren't always the same thing).
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| target_frames | INT | 16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |