Nodes/Seamless Loop (Auto Align FLV)/Seamless Loop (Auto Align FLV)
ComfyUI Node

Seamless Loop (Auto Align FLV)

Fix the hitch where your AI loop wraps around — without a blind zoom

By amagicai·Created 5 days ago·Updated 2 days ago· 0
Seamless Loop (Auto Align FLV)
  • images
  • images
max_features300
min_matches15
anchor_frameauto
transformaffine
interplog
upscale_methodbicubic
drop_last_frames1
mix_first_lastoff

You've got a loop that's almost seamless. The video model was given a first and a last frame and asked to bridge them, and every pass through the sequence looks great - until the wrap, where the last frame doesn't quite land on the first. A tiny jump, a micro-hitch, a sub-pixel flinch. It's the tell that separates a nice loop from a hypnotic one.

That's the problem this node exists for. Seamless Loop (Auto Align FLV) is the single node in amagicai's comfyui-seamless-loop pack, and it's a deterministic fixer, not a model: it re-registers every frame of your batch against one reference framing and kills the wrap hitch down to sub-pixel precision.

The key word is measure. First-last video (FLV) models leave small registration errors between their endpoint frames - a hair of drift in zoom, pan, or rotation. Older drift-compensation nodes faked this with a blind one-size-fits-all zoom that wasted resolution whether the clip needed it or not. This node instead finds real matching points between your first and last frames, fits a geometric transform to what actually happened, and corrects for exactly that. It doesn't assume your camera zoomed; it checks.

How it works

Given n frames, it detects ORB keypoints in the first and last frames, keeps only confident matches (Lowe's ratio test), and fits a RANSAC-robust 2D transform between them - a full affine by default, or a stricter similarity if you're fighting noisy footage. It even sanity-checks the fit's orientation by warping the last frame both ways and keeping whichever best reproduces the first.

Then comes the decision that matters. It picks an anchor - the frame whose framing everything else gets warped to. In auto mode it anchors to whichever endpoint is more zoomed in, so every intermediate warp is a magnification: you crop away border detail rather than invent pixels that don't exist. Each frame's warp interpolates between identity and the endpoint transform, in log space by default so a zoom ramps at constant velocity instead of decelerating.

Want a genuinely seamless wrap? Flip mix_first_last to on and it replaces output frame 0 with the 50/50 average of the aligned first and dropped-last frames (drop_last_frames must be 1, the default). Same framing, so the seam just vanishes.

The inputs that matter

Only images is a required wire - the node is an image-batch passthrough that slots between VAE Decode and your video writer. Of the rest, you'll touch maybe three:

  • transform - affine is right for most footage. similarity is more robust on wobbly, low-quality clips but can't fix anisotropic stretch. radial is the odd one out: it corrects only barrel/pincushion distortion and can't combine with the affine family, because a zoom and a barrel warp are mathematically confounded. Pick whichever describes your footage.
  • mix_first_last - on plus drop_last_frames = 1 gives you the loop-closing blend above.
  • max_features / min_matches - the "my footage is being passed through unchanged" dials (more on that below).

anchor_frame can stay on auto. The output is a single IMAGE tensor, same dtype and device as the input (it never quantizes to 8-bit), with drop_last_frames frames trimmed. Every run logs its decision to the console - matches, inliers, the drift determinant, the chosen anchor - so you can see why it did what it did.

Installing it

It's a two-line job with zero extra dependencies - just numpy, torch, and opencv-python, all of which ComfyUI already ships. Easiest route: ComfyUI Manager, search "Seamless Loop", restart. Or by hand:

cd <your-ComfyUI-dir>/custom_nodes
git clone https://github.com/amagicai/comfyui-seamless-loop

Restart ComfyUI and it appears under image/batch as "Seamless Loop (Auto Align FLV)" - searchable as seamless loop, autoalign, or compensate drift. No model downloads, no API keys, nothing to babysit.

Where people get burned

The big one is expectation. This node fixes geometric framing drift - zoom, pan, rotation, shear. It can't fix a loop whose endpoints genuinely disagree in content: if the lighting shifted or the subject morphed between first and last, no alignment pass will save it. And if there simply aren't matching features (near-black or flat footage, or a scene that changed completely), ORB finds nothing and the batch passes through unchanged - it still trims the tail, so read the console log before assuming it worked. Log showing fewer than min_matches? Lower that dial or accept there's no shared structure to register against.

Also, it resamples every frame, so expect a hair of softening - that's the price of correction, not a bug. And mix_first_last is ignored unless drop_last_frames is exactly 1, so don't puzzle over why flipping it alone changed nothing.

For a node this obscure, the polish is remarkable - 31 passing tests, per-run diagnostics, Lie-algebra interpolation. It won't rescue a bad loop, but a good loop that hitches? That's exactly what it was built for.

Categoryimage/batch

Inputs (9)

NameTypeDefaultDescription
imagesIMAGE
max_featuresINT30020–5000
min_matchesINT155–500
anchor_frameCOMBOauto3 options: auto, first, last
transformCOMBOaffine3 options: affine, similarity, radial
interpCOMBOlog2 options: log, linear
upscale_methodCOMBObicubic5 options: nearest-exact, bilinear, area, bicubic, lanczos
drop_last_framesINT10–1000
mix_first_lastCOMBOoff2 options: off, on

Outputs (1)

NameTypeDescription
imagesIMAGE