Nodes/ComfyUi-MpiNodes/Mpi Image Splice
ComfyUI Node

Mpi Image Splice

Stitch processed frames back into a clip

By MadPonyInteractive·Created 11 months ago·Updated a day ago· 3
Mpi Image Splice
  • images
  • patch
  • images
start0

Every video editing pipeline built on a video model eventually hits the same wall: the model denoises the whole latent on every step, so asking it to fix a few frames costs almost as much as generating the whole clip. The workaround is windowed editing - cut a short window of frames out, run the expensive pass on that alone, then put the result back. MpiImageSplice is the putting-back. Give it the full clip, the processed window, and the frame number where that window started, and it writes the patch in, leaving everything else untouched.

It's the small node at the end of a big workflow, and it has exactly two jobs: do the splice correctly, and refuse loudly when it can't.

How it works

Mechanically it's embarrassingly simple, which is the point. It clones the full clip and copies the patch over it: out[start : start + len(patch)] = patch. No blending, no resampling, no feathering - deliberate, not a shortcut.

Here's the reasoning. In the workflow this pack is built around - windowed MiniMax H3 inpainting - the window you're splicing back comes out of MpiH3DecodeAV, whose output outside the mask is the original pixel. Your patch's boundary is therefore bit-identical to what's already in the clip, and when the seam doesn't exist, blending would only soften it into a smear. If your patch source isn't already edge-exact, that's a problem upstream, not something a splice node should paper over.

So it doesn't try to be clever, and it doesn't hide mistakes. It checks two things and raises if either fails: the patch's canvas (height × width) must match the clip's, and the patch must not run past the end of the clip. Either mistake would otherwise land as a clip that plays but is subtly wrong.

Inputs and output

Only three inputs, all required, and none of them is a mystery:

  • images - the full clip. Returned unchanged except where the patch lands.
  • patch - the frames to write in. Whatever your expensive pass produced for the window.
  • start - the clip frame the patch's first frame lands on. Reuse the exact index the window was cut at (say with MpiListRange); it's 0-based and not clamped.

One output: images, the spliced clip, ready for the video encoder.

Why you'd actually reach for it

The flagship use is H3 inpainting on a budget. Because the sampler denoises the whole latent every step regardless of mask, masking a few frames saves no compute - but feeding the model a shorter clip does, and it can be dramatically cheaper. Cut a window with MpiListRange (picture) and MpiAudioRange (soundtrack, same frame numbers), run the inpaint on the short clip, splice the result back here, and you only paid for the frames that actually needed fixing. Beyond that: replacing a rejected segment, gluing independently generated runs together, slotting an upscaled region back into its clip - anything where a run of frames returns into a longer sequence at a known offset.

Install

It ships in ComfyUi-MpiNodes by Mad Pony Interactive, the 100-plus-node utility pack that also drives the Cubric Vision desktop app. Through ComfyUI Manager, search ComfyUi-MpiNodes and restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes

Then restart ComfyUI. Pure Python - no pip dependencies, no models to fetch. Note the pack went AGPL-3.0 at version 1.2.7 (it was MIT up to 1.2.6), which only constrains you if you redistribute the pack itself.

Troubleshooting

  • "The patch is WxH and the clip is WxH; a splice needs one canvas." Your window was resized somewhere between cutting and splicing - most commonly a VAE encode/decode round trip that didn't come back to the same size. Re-cut or re-scale the patch.
  • "A N-frame patch written at frame M runs past the end of a K-frame clip." Wrong start, or the patch is longer than you think. Remember it's the same index the window was cut at.
  • A visible seam at the boundary. Your patch's edges went through a round trip, so they don't match the clip byte-for-byte. This node won't hide it by design - pair the splice with a source that returns original pixels outside its own mask (like MpiH3DecodeAV), or blend at the seam upstream.

One aside: most "utility" video nodes try to be ten things. This one does one operation, verifies it can do it correctly, and refuses the job when it can't. After a few hours of silent video bugs, you learn to appreciate that.

CategoryMpiNodes/ImgOps

Inputs (3)

NameTypeDefaultDescription
imagesIMAGEThe full clip. Returned unchanged except where the patch is written.
patchIMAGEThe frames to write in, e.g. an inpainted window.
startINT00–4294967295The clip frame the patch's FIRST frame is written at - the same index the window was cut at.

Outputs (1)

NameTypeDescription
imagesIMAGE