Merge image batches
Patch the holes in your image batches
- batch1
- batch2
- MERGED
The name says it all and there's no hidden twist: MergeImageBatches takes two image batches, walks them index by index, and hands you back one batch where every frame is the best available of the two. "Best" here is defined as "not black." When one side is a black frame (or empty) and the other is a real image, you get the real image. When both sides have content, you pick a side via the prefer toggle. When both are black, you still get one of them - which sounds useless until you remember you're building a graph, not a pixel-perfect editor.
Why this node exists: it's the fix-up step for pipelines that produce "holes" - batches where some frames legitimately have nothing in them. The pack's own flagship face-swap workflow uses it exactly that way (examples/FaceFilter-Faceswap-Video.json): the Face Filter node rejects frames that don't contain the target face and fills those slots with a black placeholder, then MergeImageBatches stitches the swapped frames and the untouched originals back into a single batch you can save. If you've ever tried to merge two parallel branches with a plain ImageBatch node, you know what this solves: the core node just concatenates; it has no idea how to resolve "black frame vs real frame" for you.
The inputs are all you get and all you need:
batch1/batch2- two IMAGE tensors.prefer-batch1orbatch2, used when both frames are valid (or both are black).
That's it. The single output is MERGED (IMAGE), ready to feed a SaveImage, a VideoHelperSuite encode, or whatever comes next.
One real gotcha, and it's the kind that bites silently: the merge only walks as far as the shorter of the two batches - min(len(batch1), len(batch2)) - and any frames past that index are dropped, not padded. There's no warning and no error; you just lose frames off the end of one branch. If your two branches can come out at different lengths, keep them pinned to the same length upstream and you'll never hit it.
Installation is the pack's install: ComfyUI Manager, search "ComfyUI-FaceFilter", and it's done. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Kidev/ComfyUI-FaceFilter.git
pip install -r ComfyUI-FaceFilter/requirements.txt
then restart ComfyUI. Note that the node itself is pure PyTorch/numpy and needs no models at all - the heavyweight InsightFace dependency only matters if you also run the Face Filter node in the same pack.
If you just need to interleave or concatenate batches in order, stick with ComfyUI core's ImageBatch / ImageBatchMultiple. Reach for MergeImageBatches when one of your branches can produce black or empty slots and you want the other side to fill them. For that one job it's basically unbeatable in simplicity.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| batch1 | IMAGE | — | |
| batch2 | IMAGE | — | |
| prefer | COMBO | 2 options: batch1, batch2 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MERGED | IMAGE | — |