Nodes/Link Comfy Nodes/WAN Loop Bridge
ComfyUI Node

WAN Loop Bridge

Fix the Seam, Not the Whole Loop

By Mister-Link·Created 11 months ago·Updated 2 days ago· 2
WAN Loop Bridge
  • frames
  • frames
  • mask
  • frame_count
  • metadata
  • context_frames
  • raw_frames
◄skip_end_frames4►
◄skip_begin_frames4►
◄insert_frames4►
◄context_frames4►

Anyone who's tried to loop WAN knows the two bad options. Use first-last-frame with the same image on both ends: the motion dies, because you've told the model the destination is the origin. Use image-to-video and let it run free: the motion is great, then the playback jumps at the wrap. "It technically loops, but the transition still doesn't feel natural - there's a small visual jump that breaks the flow" is how one thread puts it, and that's the state of the art without extra machinery.

WAN Loop Bridge is the extra machinery. It stops asking the model to return to frame zero, and replaces the bad join with frames the model actually generated, with real footage on both sides to lean on.

The idea in one sentence

Cut the last few frames and the first few of your clip out, mask that gap, generate new frames into it with WAN's masked video sampling so they're guided by genuine context on either side, then splice them back in.

That's it. The model never has to invent how to land on a specific frame; it just has to carry motion through a gap. A much easier problem, and the one WAN is good at.

What the node does mechanically

You feed it the whole animation as an IMAGE batch. It treats skip_end_frames and skip_begin_frames as the seam window - the frames you're throwing away. Everything else is "source", and survives untouched.

It then takes context from immediately outside the window: context_frames total, split with the extra frame going to the before side on odd values (4 gives 2 before, 2 after). Those frames go into the output batch as guides. The replacement window itself becomes blank white frames - that's the hole to be filled.

Then the part that saves you from WAN's arithmetic. A sampling segment has to be a valid 1 + 4n length, and your window almost certainly isn't. So it pads the segment with extra frames at either end from just outside the context, and masks those black. Padding is sampler scaffolding, not content - it will be thrown away later. If it can't resolve to 1 + 4n, it raises rather than sending WAN something invalid.

The inputs

  • frames - the full source animation, seam and all.
  • skip_end_frames - raw frames dropped off the end, default 4.
  • skip_begin_frames - raw frames dropped off the front, default 4.
  • insert_frames - how many generated frames you want back, default 4. This is the only number that changes final length.
  • context_frames - total guide frames outside the window, default 4, minimum 2. More context means steadier motion and a longer sampling segment.

Skip counts must leave at least one source frame, and context_frames has to fit within what's left - both are hard errors with readable messages.

The outputs, and where each one goes

Six of them, and they aren't interchangeable.

  • frames → into your WAN masked sampling (VACE or an inpainting-style video pass) together with
  • mask → white only over the frames you want generated; padding is black, so the sampler knows what's real.
  • context_frames → the actual length of that segment. Wire it into whatever needs a WAN-valid count.
  • metadata → a JSON string. You must wire this into WAN Unloop Bridge. Don't retype it, don't edit it.
  • frame_count → the final length of the finished animation, not the segment length. This is what your output encoder should expect.
  • raw_frames → the untouched original, passed straight to the Unloop node.

Then you sample, feed the segment plus raw_frames and metadata into WAN Unloop Bridge, and get your loop.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
cd link-comfy-nodes
pip install -r requirements.txt

Manager: search Link Comfy Nodes. The README is one sentence - "use at your own risk, I change how nodes behave without warning" - and there's no docs, no examples, and effectively zero Reddit footprint. Save your working graph.

Where people get burned

Assuming the output is WAN-valid. The final length frame_count won't necessarily be a WAN-valid 1 + 4n, which is fine for playback and a problem if you plan another sampling pass. Check the metadata's WAN-valid flag before chaining.

Assuming insert_frames is additive to the segment. It's additive to the final animation. The segment is bigger than your insertion count because it carries context and padding.

Losing the pair. These two nodes are a contract, not a toolkit - delete the bridge after sampling and the Unloop node has nothing to validate against.

Categoryconditioning/video_models

Inputs (5)

NameTypeDefaultDescription
framesIMAGEFull source animation containing the seam to replace.
skip_end_framesINT40–9998Raw frames skipped at the end of the animation before the generated bridge; context is taken immediately before these frames.
skip_begin_framesINT40–9998Raw frames skipped at the beginning of the animation after the generated bridge; context is taken immediately after these frames.
insert_framesINT41–9998Number of generated frames inserted into the skipped seam; sampler-only padding is added separately when needed for a WAN-valid segment.
context_framesINT42–9998Total source guide frames outside the replacement window; odd values give the extra frame to the before side.

Outputs (6)

NameTypeDescription
framesIMAGEContext before the seam, masked replacement frames, and context after the seam.
maskMASKWhite only for frames that will be inserted into the final animation; sampler padding is black.
frame_countINTFinal full-animation frame count after skipping seam frames and inserting the requested frames.
metadataSTRINGMetadata for WAN Unloop Bridge to remove the seam window and insert only generated frames.
context_framesINTActual WAN-valid frame count of the sampling segment.
raw_framesIMAGEUntouched original animation batch for WAN Unloop Bridge.