Nodes/KJNodes for ComfyUI/ImageBatchRepeatInterleaving
ComfyUI Node Runs on cloud

ImageBatchRepeatInterleaving

Hold each frame N times to stretch a batch

By kijai·Created 3 years ago·Updated a day ago· 2,908
ImageBatchRepeatInterleaving
  • images
  • mask
  • IMAGE
  • MASK
repeats1

This node repeats each image in a batch a set number of times, in place. Feed it five frames labeled 0,1,2,3,4 with repeats set to 2, and you get ten frames: 0,0,1,1,2,2,3,3,4,4. Note the difference from just duplicating the whole batch - it holds each frame in sequence rather than looping the set. That "interleaving" is the entire behavior, and it's more useful than it sounds.

Where you reach for it: stretching a short batch to hit a target frame count, holding keyframes so each shows for longer, or prepping frames for an interpolation pass. If you've got 20 generated frames and a downstream node wants 40, interleaving with repeats 2 doubles the length while keeping the order intact.

How it works

It's a repeat-interleave, borrowed straight from the tensor operation of the same name. Each element is duplicated back-to-back before moving to the next. That's different from tiling (0,1,2,3,4,0,1,2,3,4), which loops the whole sequence - here 0 comes twice, then 1 twice, and so on. For video that means each source frame lingers on screen for repeats frames instead of the clip playing through twice.

It's another of the small, dependency-light utilities that make up Kijai's KJNodes pack. No cleverness, just the exact reshaping you'd otherwise write by hand.

The inputs and outputs that matter

  • images (IMAGE) - the batch to stretch.
  • repeats (INT, default 1) - how many times to hold each frame. At 1 it's a passthrough; 2 doubles, 3 triples, and so on. This is the only real knob.
  • mask (MASK, optional) - pass a matching mask batch and it gets interleaved the same way, so your masks stay aligned with the frames.

Outputs are IMAGE (the stretched batch) and MASK (the stretched masks, if you gave it any). Wire the image into your video combine, a sampler, or an interpolation node.

How to install it

ComfyUI Manager: search KJNodes for ComfyUI, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt

Restart and it's under KJNodes/image. No models, minimal deps.

Common issues & troubleshooting

The video stutters instead of playing smoothly. That's expected - repeat-interleave holds each frame as a hard duplicate, so playback looks like a slideshow at low repeat counts, not smooth slow motion. If you want genuinely smooth slow-mo, you want frame interpolation (a RIFE/FILM-style node that generates in-between frames), not repetition. Use this node to hold frames deliberately, not to fake fluid motion.

My mask went out of sync. If you stretch the images but forget the mask, they no longer line up frame-for-frame. Route the matching mask batch through this node's mask input so both get the same interleaving.

I wanted the batch to loop, not hold. Repeat-interleave isn't tiling. If you want 0,1,2,0,1,2 (the whole sequence repeated), this is the wrong node - that's a batch concatenation/repeat, not an interleave. This one only ever holds each frame in place.

Frame count ballooned. Output length is input_count × repeats. It's easy to forget you're multiplying - a 60-frame batch at repeats 4 becomes 240 frames, which your downstream sampler will happily try to process. Watch the multiplier.

CategoryKJNodes/image

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
repeatsINT11–4096
maskoptMASK

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK