Nodes/KJNodes for ComfyUI/Cut And Drag On Path
ComfyUI Node Runs on cloud

Cut And Drag On Path

The After Effects trick, but inside ComfyUI

By kijai·Created 3 years ago·Updated about 20 hours ago· 2,930
Cut And Drag On Path
  • image
  • mask
  • bg_image
  • image
  • mask
coordinates
frame_width512
frame_height512
inpainttrue

Some of the best motion-control results in local video generation right now start with a deliberately crude edit: cut an object out of a photo, drag it to a new spot, and hand that rough, physically-wrong composite to a video model as a hint about where things should move. People have been doing this by hand in Adobe After Effects - cutting a car out of a still and manually keyframing it across the frame before feeding the sequence into Wan. Cut And Drag On Path does the exact same operation natively in ComfyUI: no separate editor required.

Why this specific trick matters

This isn't a generic compositing gimmick - it's the prep step behind Time-to-Move (TTM), a motion-control technique that went viral on r/StableDiffusion for how well it worked on Wan 2.2. The idea: you don't need a perfect edit, just a rough one that shows the model where an object should end up; a TTM-style model patch then uses that crude motion as guidance during early denoising and lets the model clean it up into physically coherent movement. The bottleneck was always producing that rough cut-and-drag video in the first place - which is why people were reaching for full video-editing software just to move a cutout across a few frames. This node removes that dependency.

How it works

Give it an image and a mask marking the object you want to move, plus a coordinates path describing where it travels. The node cuts the masked region out and drags it along that path frame by frame, building a batch sized to frame_width/frame_height. What happens to the hole left behind depends on your setup: supply a bg_image and the cutout composites over it at each position; leave bg_image empty with inpaint left on (the default) and the gap gets filled automatically using OpenCV's TELEA algorithm - a well-established, fast inpainting method that fills a hole by propagating nearby pixel information inward, no diffusion model involved.

The inputs and outputs that matter

  • image and mask (required) - your source and the region to cut and drag.
  • coordinates (STRING) - the path the cutout travels along.
  • frame_width / frame_height (default 512, 16–4096) - output frame size for the resulting sequence.
  • inpaint (default true) - fill the vacated area with TELEA inpainting when no background is supplied.
  • bg_image (optional) - composite the moving cutout over this instead of inpainting the hole.
  • Outputs: image (the frame sequence) and mask (tracking the cutout's position per frame - genuinely useful downstream if a later node needs to know exactly where the moved object is at each step, such as a TTM-style guidance mask).

Installing it

Ships with the pack:

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, restart.

No models to download for this node specifically - TELEA inpainting runs through OpenCV, a standard dependency, not a checkpoint.

Common issues & troubleshooting

The inpainted background looks rough or smeared. That's TELEA doing what a fast, non-generative inpainting algorithm does - it's built for speed and plausibility on simple backgrounds, not for reconstructing fine detail. For a clean, complex background, supplying your own bg_image will beat TELEA every time; save the auto-inpaint for quick tests or simple, low-detail backdrops.

The output looks like a rough, obviously-composited edit. That's expected, and it's the whole point of this technique - you're not trying to produce a finished-looking video here, you're building the crude motion hint that a downstream model (like a TTM-style patch) is meant to clean up. Judge the output by whether the path and timing are right, not by whether it looks polished on its own.

Cutout doesn't line up with my intended path. Double-check your mask actually isolates the object you mean to move - a mask that's too loose or too tight will drag extra background or clip part of the subject along with it, which shows up as artifacts at the edges of the moving region.

CategoryKJNodes/image

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
coordinatesSTRING
maskMASK
frame_widthINT51216–4096
frame_heightINT51216–4096
inpaintBOOLEANtrue
bg_imageoptIMAGE

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK