Nodes/ComfyUI-Image-Filters/Merge Frames By Index
ComfyUI Node

Merge Frames By Index

Splice a processed handful of frames back into the full batch

By spacepxl·Created 3 years ago·Updated 8 months ago· 293
Merge Frames By Index
  • index_list
  • orig_images
  • images
  • orig_masks
  • masks
  • images
  • masks

Video workflows in ComfyUI have a recurring cost problem: running an expensive node (a heavy model pass, an inpaint, a restoration step) on every single frame of a long batch is slow and often wasteful, because a lot of what you'd do to fix one frame is redundant across neighboring frames. The README names the pattern this node is half of: "Extract N Frames, Merge Frames By Index - For processing a smaller number of frames evenly distributed across a larger batch/video, then merging them back into the full batch." You pull out a representative subset, process just those, then use this node to put them back where they came from.

How the pattern works end to end

Step one - not covered here - is pulling a sparse, evenly-spaced subsample out of your full video batch (the README's paired "Extract N Frames" node handles that half, along with the list of which indices it grabbed). You run your expensive processing on that smaller subset only. Then Merge Frames By Index takes the original full batch, the processed subset, and the index list that says which position each processed frame belongs at, and reassembles a full-length batch where those specific positions are replaced with the processed versions and everything else is untouched. It's the difference between paying for an expensive operation on every frame versus paying for it on a handful and accepting the rest stay as they were (or get handled some cheaper way).

Inputs and outputs

  • index_list (LIST) - which positions in the original batch correspond to the processed frames. This has to be the same list your extraction step produced.
  • orig_images (IMAGE) - the full, original batch you're merging back into.
  • images (IMAGE) - the smaller, already-processed subset.
  • orig_masks / masks (MASK, both optional) - the same merge logic applied to masks, if your pipeline is carrying masks alongside the image batch.

Two outputs: images, the full-length batch with the processed frames spliced into their original positions, and masks, the equivalent for mask data when supplied.

Installing it

ComfyUI Manager: search "ComfyUI-Image-Filters," install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters

pip install -r requirements.txt (or install.bat on Windows), restart. This is pure batch/index bookkeeping - no models to download.

The pack-wide OpenCV note applies here too: a conflicting cv2 build from another custom node pack can cause import errors for this entire repo on startup, not just this specific node. import_error_install.bat resolves it by reinstalling the single correct opencv variant the pack needs.

Common issues

The whole thing hinges on index_list staying in sync with how you extracted the subset in the first place - if that list doesn't match the actual positions your processed frames came from, you'll get frames spliced into the wrong spots in the batch, which is a subtle bug rather than a crash: everything will run, but your video will have a processed frame showing up at the wrong time. Double-check that the index_list feeding this node is the exact one your extraction step produced, not a hand-typed guess. Second, orig_images and images need to actually correspond frame-for-frame with what index_list claims - if the processed subset's ordering doesn't match the index list's ordering, the merge will scramble which processed frame lands where.

CategoryImage-Filters/image/frames

Inputs (5)

NameTypeDefaultDescription
index_listLIST
orig_imagesIMAGE
imagesIMAGE
orig_masksoptMASK
masksoptMASK

Outputs (2)

NameTypeDescription
imagesIMAGE
masksMASK