Batch Merge (mtb)
Combine image batches with different frame counts in ComfyUI
- IMAGE
Blending two image sequences frame-by-frame is easy - until they're different lengths. A 24-frame clip and a 30-frame clip don't line up, and most nodes just choke. Batch Merge (mtb) is built for exactly that: it merges multiple image batches even when their frame counts don't match, and it combines the overlapping frames however you tell it to.
This is an animation/compositing tool. Say you've generated two AnimateDiff sequences and want to overlay them - a base render and a light-leak pass, or two variations you want to average into something smoother. Batch Merge stacks them per-frame and fuses them. The "different frame counts" handling is the actual selling point; without it you'd be manually padding or trimming one sequence to match the other before you could combine anything.
It's in the batch section of MTB Nodes (comfy_mtb) by melMass, alongside its other batch-manipulation nodes.
How it works
You feed it multiple image batches, and it aligns them frame-by-frame and fuses each aligned pair of frames with a pixel operation. Because the batches can be different lengths, it has to decide how to align the shorter one against the longer - and how to fill the gap. Once aligned, each pair of frames is combined with the math you pick. It's tensor arithmetic on the image data, so no model and no network.
The inputs and outputs that matter
Two controls, and they map directly onto the two decisions the node has to make:
fusion_mode(add / multiply / average, defaultaverage) - how overlapping frames combine.averageblends them evenly (the safe, natural-looking default).addbrightens where they overlap (good for light/glow passes).multiplydarkens (good for shadow or texture passes). If you've used blend modes in Photoshop, these behave the way you'd expect.fill(head / tail, defaulttail) - how to handle the length mismatch, i.e. which end gets padded when one batch is shorter.tailpads/aligns at the end;headat the start. This is the knob that decides whether your short clip lines up with the beginning or the end of the long one.
You wire the image batches you want to merge into the node, and it returns a single merged IMAGE batch.
How to install it
ComfyUI Manager: search MTB Nodes, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb
then restart. Pure Python tensor work - no models, no heavy dependencies.
Common issues & troubleshooting
Resolution mismatch errors. Frame counts can differ, but the frame dimensions can't - every image being merged has to be the same width and height, because you can't do pixel math across mismatched grids. Resize your batches to a common size first.
The overlap blew out to white (or crushed to black). That's fusion_mode. add piles brightness up and can clip to white; multiply stacks darkness toward black. If the combine looks extreme, switch to average, which stays in range by construction.
The clips line up at the wrong end. Flip fill between head and tail. If your short overlay is landing at the start of the sequence when you wanted it at the end (or vice versa), that toggle is the fix.
Only two of my batches merged. Make sure each batch is actually wired into its own input slot; an unconnected input contributes nothing to the merge.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| fusion_mode | COMBO | average | 3 options: add, multiply, average |
| fill | COMBO | tail | 2 options: head, tail |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |