Nodes/Difforum/Difforum · Loop Blend (perfect loop)
ComfyUI Node

Difforum · Loop Blend (perfect loop)

Morph the tail into the head along optical flow

By chillithebillis·Created 3 months ago·Updated about a month ago· 7
Difforum · Loop Blend (perfect loop)
  • frames
  • frames
blend_frames12
flow_aligntrue

Ping-pong loops are easy but they reverse your motion, and crossfades hide the seam without fixing it. Difforum Loop Blend is the "have it both ways" option: a forward-only loop where the tail of the clip morph-fades into the head - aligned along optical flow so the dissolve happens with the motion instead of through it. No reversed playback anywhere.

It takes a frame batch, blend_frames (how many frames the morph spans, default 12), and flow_align (on by default - it aligns the tail to the head along estimated motion before blending, which is what stops the dissolve from looking like a lazy crossfade). The output is a shorter batch: N - blend_frames frames, because the tail that got melted into the head is consumed. That's the one thing that catches people - the output length isn't the input length.

When it's the right tool

Loop Blend is the practical answer when your motion must keep running forward but your camera isn't periodic. Typical case: you generated a Deforum-style clip, the motion is good, but frame 0 and frame N-1 don't meet. Run Loop Blend and the last 12 frames dissolve into the first 12 along the flow - a moving, breathing transition instead of a hard cut. It's wired into the render templates for exactly this reason: as a cleanup stage after the feedback sampler.

Where it's not the right tool: if you're building a loop that runs for hours (a VJ projection), a morph is still a patch - the eye eventually finds a transition that never quite repeats. The README's honest framing is that for genuinely seamless loops you want a periodic camera path plus settled laps (Seamless Camera + Loop Take), and you don't need this node at all. Loop Blend is for when the clip already exists and you just need it to loop once, believably.

Inputs and gotchas

Inputs: frames (IMAGE batch), blend_frames (0–120; 0 effectively disables the morph), flow_align (BOOLEAN). Output: frames.

Install is the shared pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/chillithebillis/Difforum.git difforum

Restart ComfyUI ([Difforum] loaded N nodes; ComfyUI Manager also has "Difforum"). Deps: numpy, already present. One practical tip: blend_frames too small (under ~8) and the morph is a visible cut; too large and you lose a noticeable chunk of the clip's runtime. And like every frame-based node here, feed it the batch after any resize - the flow alignment is computed at whatever resolution you give it.

CategoryDifforum/effects

Inputs (3)

NameTypeDefaultDescription
framesIMAGE
blend_framesINT120–120
flow_alignBOOLEANtrue

Outputs (1)

NameTypeDescription
framesIMAGE