Nodes/ComfyWarp/WarpFrame
ComfyUI Node

WarpFrame

The node that makes video frames agree with each other

By Sxela·Created 3 years ago·Updated about a month ago· 49
WarpFrame
  • previous_frame
  • flow
  • IMAGE

This is the heart of ComfyWarp - the node the whole pack exists for. Frame-by-frame img2img has one problem that ruins everything: each frame is generated independently, so your stylized video shimmers and flickers as the model re-imagines the same shot a hundred times. WarpFrame attacks that directly. It takes your previously generated frame, physically moves its pixels to match the motion in the source video, and hands that back as the starting point for the next frame. The model no longer has to reinvent everything - it only restyles what actually changed.

This is the WarpFusion trick, ported to ComfyUI. WarpFusion was Sxela's Colab pipeline that stylized real video frame by frame, and it was the serious alternative to Deforum's zoom-and-morph approach back in the SD 1.5 era. Where Deforum hallucinated camera moves, WarpFusion used real per-pixel motion from the footage. ComfyWarp puts that in your graph.

How it works

The node is small on purpose. It takes two inputs and does one job:

  • previous_frame (IMAGE) - your last stylized frame, the output of the previous iteration's sampler.
  • flow (BACKWARD_FLOW) - the optical flow between two frames of the source video. This has to come from the pack's own "Extract optical flow" node - it's the only node in the ecosystem that emits this custom type. If the socket won't connect, you're plugging in the wrong thing.

Behind the scenes the warp is old-school OpenCV remapping: it pads the flow field by 20%, reflect-pads the frame, warps pixel-by-pixel with Lanczos interpolation, and crops back. The flow itself is the clever part - it's computed by a real RAFT optical-flow model (torchvision's raft_large), which runs on CUDA if you have it and downloads its weights automatically on first use. So there's no model file to fetch manually, but do expect that first flow computation to pull down RAFT weights and then run.

The single output is an IMAGE - the warped previous frame. In the loopback workflow it flows into your img2img/sampler path as the base image, with the current raw frame as the conditioning target. On top of that loop the pack layers consistency masks (occlusion, edges, borders from the flow extraction) that tell the sampler which areas are unreliable and should be regenerated rather than warped - that's the deflicker magic. WarpFrame alone is just the warp; the masks are what make it look good.

Installing it

The standard way, same as the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Sxela/ComfyWarp

Restart ComfyUI, or search "ComfyWarp" in ComfyUI Manager. Dependencies are opencv-python and scikit-image plus the torchvision that ships with ComfyUI. RAFT weights download on first run. Skip the pack's install.bat - that's a 2023-era self-contained installer that sets up its own Python and torch; on a modern ComfyUI you don't want it.

Where people get burned

  • Wrong flow socket. BACKWARD_FLOW only connects to the pack's own Extract optical flow node. Red connection = wrong node, not a bug.
  • Size mismatch. Flow and frame must match dimensions; upsizing mid-pipeline is the usual way to break this.
  • First-run download. The RAFT weights fetch from torchvision on first flow extraction. On a fresh install the first frame looks like a hang; it's downloading.
  • Old code. This pack peaked in 2023 and maintenance has been sporadic, so a ComfyUI update may shake it loose. It still gets cited in animation circles for the one thing it does - real, footage-grounded motion - better than anything that replaced it.

If you're doing stylized video on real footage, this is the node that makes it stop flickering. Give it a properly warped previous frame and honest flow, and the sampler does the rest.

CategoryWarpFusion

Inputs (2)

NameTypeDefaultDescription
previous_frameIMAGE
flowBACKWARD_FLOW

Outputs (1)

NameTypeDescription
IMAGEIMAGE