ComfyUI Node

RAFT Run

Turn any video into reusable motion data

By chaojie·Created 3 years ago·Updated 2 years ago· 28
RAFT Run
  • images
  • OPTICAL_FLOW
  • IMAGE

Motion you can actually reuse

ComfyUI-RAFT is a one-trick pack, and the trick is a good one: it reads the motion out of a video and saves it as a reusable "motion brush" you can later paint onto other images. RAFT Run is the engine - the node that does the actual motion-sensing. You feed it a batch of frames and it hands back two things: the raw optical flow between every pair of consecutive frames (OPTICAL_FLOW) and a color-coded picture of that motion (IMAGE).

Why bother? Because motion is the part of image animation nobody can author by hand. Runway's Gen-3 ships a "Multi-Motion Brush" that lets you paint where things move; this is the open-source version of that idea, split across two packs by the same author - this one captures motion from real footage, and ComfyUI-DragNUWA paints it onto your still images. RAFT Run is the capture half.

How it works - the actual RAFT

RAFT is the Recurrent All-Pairs Field Transforms optical-flow network from Princeton (ECCV 2020), and it earns its acronym. Instead of estimating flow in one shot, it builds a 4D correlation volume - the similarity of every feature patch in frame A against every patch in frame B - then a recurrent update operator (a GRU) iteratively refines the flow field, each pass looking up where the current flow lands in that volume and nudging it. This node runs 20 of those iterations, pads frames to a multiple of 8 internally, and strips the padding before returning. The result is dense, smooth, sub-pixel flow rather than blocky motion vectors. It's not a new idea in 2026, but it's still the right tool for the job - nothing in the standard ComfyUI install does this for you.

The inputs and outputs that matter

There's exactly one input, and it's not a parameter you tweak:

  • images (IMAGE) - a batch of video frames. You're almost never generating this yourself. Load a clip with VideoHelperSuite's VHS_LoadVideo and wire its IMAGE output straight in. The author's own workflow does precisely that, capped at 14 frames.

Outputs:

  • OPTICAL_FLOW - the raw flow, one field per frame pair. This is the money output. Feed N frames in and you get N−1 flow fields back.
  • IMAGE - the same motion rendered as a color map (hue = direction, brightness = speed), ready for a PreviewImage. Great for a quick sanity check that the clip actually moves the way you thought it did.

Install

Install it once and it's done for all four nodes in this pack. ComfyUI Manager: search ComfyUI-RAFT, hit install. Or, by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/chaojie/ComfyUI-RAFT

Restart ComfyUI. requirements.txt is a single line (scipy), and the ~21 MB raft-things.pth weights are bundled right inside the repo at models/raft-things.pth - no separate Hugging Face download, which is a genuine relief for a 2024-era pack.

Where people get burned

  • CUDA only, no exceptions. DEVICE is hardcoded to 'cuda' with no CPU or Apple-silicon fallback. On a Mac or a CPU-only box, this node dies at the first frame. That's also why this pack never took off with the Mac crowd.
  • You need at least two frames. One frame in means an empty flow list and a torch.cat crash - a confusing error if you're testing with a single still.
  • Keep the folder named ComfyUI-RAFT. The model path is hardcoded to custom_nodes/ComfyUI-RAFT/models/raft-things.pth; rename the folder and the load fails.
  • Missing cv2. The node imports OpenCV at module load, but requirements.txt only lists scipy. If ComfyUI won't start after install and complains about cv2, pip install opencv-python in your ComfyUI environment.
  • Recomputes every run. It's fast, but if you only want the visualization and you're re-running constantly, you're redoing flow work each time. That's what Save/Load MotionBrush exist to avoid.
CategoryRAFT

Inputs (1)

NameTypeDefaultDescription
imagesIMAGE

Outputs (2)

NameTypeDescription
OPTICAL_FLOWOPTICAL_FLOW
IMAGEIMAGE