Nodes/KJNodes for ComfyUI/Accumulation to Batch
ComfyUI Node Runs on cloud

Accumulation to Batch

Where looped frames finally become one video

By kijai·Created 3 years ago·Updated 3 days ago· 3,213
Accumulation to Batch
  • accumulation
  • result
overlap_frames0
overlap_modedisabled

_AccumulateNode collects loop iterations into a list; this node is what turns that list back into something you can actually use. _AccumulationToImageBatch takes an ACCUMULATION - a list of IMAGE/MASK tensors or LATENT dicts - and concatenates them into a single batch. It's the finishing step of every TensorLoopClose workflow, and it's also where the pack's crossfade blending actually happens. You'll never add it from the menu (dev-only, like the rest of the machinery), but when a loop workflow expands you'll see it sitting right before the VAE decode.

How it works

The hard part of joining looped video isn't the joining - it's knowing which dimension to join along. Images and masks are 4D tensors (B, C, H, W), so they concatenate along the batch dimension (dim 0). Image latents are dicts whose samples are 4D, so same thing. But video latents are 5D (B, C, T, H, W) - or nested tensors holding several of them - and those concatenate along the temporal dimension (dim 2). Get this wrong and you get a "batch of videos" instead of "one long video," which is exactly the bug people hit hand-rolling this. The node inspects each item's shape and picks the right axis, and it's careful with per-frame noise masks: if every item has one it concatenates them; if any is missing, it drops the mask rather than produce one that doesn't cover the frames.

The inputs that matter

  • accumulation (ACCUMULATION) - the running list from _AccumulateNode. Required.
  • overlap_frames (int, default 0) - how many frames at each seam to crossfade, used with the fade modes below.
  • overlap_mode (combo, default "disabled") - disabled, fade_linear, or fade_smooth. fade_linear blends each seam with a linear ramp; fade_smooth uses a smoothstep (ease-in/out) ramp, which tends to look less mechanical on video.

When a fade mode is active, the node doesn't just concatenate - it takes the tail of each chunk and the head of the next, lerps them together across overlap_frames, and splices the blended result in. It clamps overlap_frames so it can't slice past the edge of a short chunk, and falls back to plain concatenation if there's nothing to blend. This is the whole reason the accumulation exists: you can't crossfade chunk N and chunk N+1 until you've seen both.

The output

One result - a single concatenated batch of whatever you accumulated: IMAGE/MASK tensors or LATENT dicts, ready for a VAE decode. If the accumulation is empty you get None, which is ComfyUI's way of saying "nothing happened."

Install

Standard pack drill:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-NativeLooping_testing

Restart ComfyUI, or install via Manager ("NativeLooping"). Nothing to download beyond a current ComfyUI.

Worth knowing: this is a _testing repo from kijai, the candidate for ComfyUI's native loop nodes, so treat internals as moving. And note the division of labor with TensorLoopClose's overlap setting - the hard-cut trim modes (start/end) happen per-iteration inside the Close node, while the fade modes are deferred to this node, post-loop. If you set a fade mode and see no blending, check that the overlap frames actually fit inside your chunks; if your chunks are tiny the clamp kicks in and it silently concatenates.

Categoryadvanced/looping

Inputs (3)

NameTypeDefaultDescription
accumulationACCUMULATION
overlap_framesINT0
overlap_modeCOMBOdisabled3 options: disabled, fade_linear, fade_smooth

Outputs (1)

NameTypeDescription
result*