Batch Align (RAFT)
Warp a batch of frames onto one reference with optical flow
- images
- aligned
- flow
Most of this pack's nodes are simple pixel math - blurs, statistics, gradients. This one's different: it runs RAFT, a real neural optical-flow network, to estimate motion between frames and warp everything in your batch to line up with a chosen reference frame. If you've got a batch with real motion in it and you need the frames actually aligned - not just similar, but pixel-registered - before doing something like averaging or temporal filtering, this is the node that does it properly instead of assuming your frames already match.
What it's actually solving
Optical flow estimates, for every pixel, where that pixel moved to (or came from) between two frames. RAFT is the well-established neural approach to this - given two frames, it outputs a dense motion field. Batch Align uses that motion field to warp every frame in your batch toward a single reference frame, so that after alignment, the same physical point sits at the same pixel location across the whole batch. That's a meaningfully different (and better) result than just hoping your frames are already close enough, which matters a lot for anything downstream that averages or compares across the batch - Batch Average Image or Batch Normalize (Latent), for instance, both assume roughly-aligned input, and motion in your source footage will show up as ghosting if you skip alignment first.
Inputs and outputs that matter
images- your batch to align.ref_frame(default 0) - which frame in the batch everything else gets warped toward.direction-forwardorbackward, controlling which way the flow is computed relative to the reference.blur(default 0) - optional blur applied to the flow field itself, which can smooth out noisy motion estimates on tricky footage.
Outputs: aligned - your warped, registered batch - and flow, the raw motion field as an image, useful for sanity-checking the alignment or feeding into something else that wants motion data.
Installing it
ComfyUI Manager, search ComfyUI Image Filters, or clone by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters
Restart afterward. This is the one node in the pack that's noticeably heavier than the rest - RAFT is an actual neural network, not a math filter, so expect it to be slower and to pull more compute than everything else in this pack. It may also need to fetch its pretrained weights the first time you use it, so give it a moment (and make sure you're online) the first time rather than assuming it's hung. The pack-wide opencv dependency applies here too: conflicting opencv installs from other node packs cause import errors, fixed by the repo's import_error_install.bat or by manually keeping only opencv-contrib-python.
Where people get burned
This is overkill - and slow overkill - for a batch that's already well-aligned (a set of img2img variations on the same composition, say). Save it for footage or sequences with genuine motion: video frames, a burst of photos with camera shake, anything where the content actually moved between frames. If your batch doesn't have real motion, skip straight to whatever averaging or normalization node you actually need.
Large or fast motion is also where RAFT can visibly struggle - big displacements between frames are the classic failure case for optical flow in general, and you may see warping artifacts around fast-moving edges. If flow looks noisy or the aligned output has visible warping artifacts, that's usually the motion being too large or too fast for clean estimation, not a setting to fix - try aligning adjacent frame pairs instead of jumping to a distant reference frame.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| ref_frame | INT | 0 | — |
| direction | COMBO | 2 options: forward, backward | |
| blur | INT | 0 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| aligned | IMAGE | — |
| flow | IMAGE | — |