Merge Media π
Composite, dissolve, and overlay clips without leaving ComfyUI
- foreground
- background
- images
Every now and then you want to lay one clip on top of another - captions over footage, a logo, a crossfade - and dragging the whole thing into DaVinci feels like overkill. Merge Media π, the third node in the ComfyUI Unified Media Suite, composites a foreground over a background right in the graph, with alpha support. It's explicitly modeled on DaVinci Resolve's merge node, and it does one useful bonus trick: the output is always scaled to the background's dimensions, so you can abuse it as an in-graph resizer.
How it works
Give it two batched IMAGE tensors and it does the compositing math itself, in PyTorch, on the CPU. The foreground is stretched or compressed to match the background's size via bilinear interpolation. Alpha is handled as a separate channel - if a layer has no alpha, it's treated as fully opaque - and both layers' alpha channels are blended regardless of which blend mode you pick. If one clip is shorter in frames than the other, the shorter one (and its alpha) is looped to pad itself out.
Two honest caveats from the source and README. First, the author runs the whole thing on CPU on purpose: compositing in VRAM blew up GPU memory with the whole clips loaded, so the trade-off is speed. Second, the blend-mode formulas are taken from Wikipedia's blend modes page, and the code comment is not reassuring - the author's own words are that the formulas are "confusing AF and are probably totally wrong. I think 'Normal' is right tho." So: trust Normal, treat the fancy modes as experiments.
Inputs
- foreground / background (required) - the two IMAGE tensors, foreground on top.
- blend (default 1.0, min 0.01) - how much foreground to overlay. The interesting part: the README suggests animating this per-frame to create dissolves between clips, or fading in alpha-layered text/captions with easing.
- blend_mode - Normal, Multiply, Screen, Overlay, Soft Light, Hard Light, Difference, Darken, Lighten. See the "totally wrong" caveat above.
- swap_inputs - flips foreground and background, handy when experimenting with blend modes (another Resolve-ism).
- foreground_image_shape / background_image_shape / output_image_shape - the pack's usual
B-H-W-CvsB-C-H-Wlayout toggles, set to match what you're feeding in and what you want out.
Output
One images tensor - the composited, alpha-included result. Note it's just frames: no fps, no audio. Those come back into play when you pipe this into Save Media and set the frame rate yourself.
Wiring it into a workflow
The natural pattern is Load Media β Merge Media β Save Media: load a background clip, load a foreground (a video, or frames from a text-overlay or logo workflow), merge, and write the result. Because alpha survives, overlaying a render of text on a transparent background onto footage is the cleanest use. And since the foreground always stretches to fit the background, it'll also happily rescale a mismatched clip - the README calls out resize as a legit use.
Common issues
- It's slow on long clips - expected. Whole foreground, whole background, both alpha channels, plus looping padding all live in system RAM while the blend runs on CPU. The author's FAQ sketches a GPU-batched rewrite as a future idea ("I'm guessing it WOULD be worth it"). Keep clips short or cut frame counts before merging.
- "The composition looks screwy" - the README's own FAQ answer: it's possible the blending formulas are just wrong. One fix it suggests is freeing the model and node cache via ComfyUI Manager. And again, the non-Normal modes are the suspects.
- Frame rates are ignored - Merge doesn't look at fps, so layering a 24fps clip over a 30fps one drifts. Align frame rates before merging, per the README.
- Unexpected dimensions - remember the output matches the background, so if sizes surprise you, check which layer is which (or flip
swap_inputs).
Install is the shared suite recipe: cd ComfyUI/custom_nodes && git clone https://github.com/fat-tire/comfyui-unified-media-suite, or search ComfyUI Manager for "ComfyUI Unified Media Suite", then restart. Dependency is just av (PyAV), no models. Like its siblings this is a Preview Beta from a single maintainer - for serious NLE-grade compositing you'd still reach for real software, but for keeping an overlay in the graph, Normal mode plus alpha gets you there.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| foreground | IMAGE | β | |
| background | IMAGE | β | |
| blendopt | FLOAT | 1.000.01β1 | β |
| foreground_image_shapeopt | COMBO | B-H-W-C | 2 options: B-H-W-C, B-C-H-W |
| background_image_shapeopt | COMBO | B-H-W-C | 2 options: B-H-W-C, B-C-H-W |
| output_image_shapeopt | COMBO | B-H-W-C | 2 options: B-H-W-C, B-C-H-W |
| blend_modeopt | COMBO | Normal | 9 options: Normal, Multiply, Screen, Overlay, Soft Light, Hard Light, +3 |
| swap_inputsopt | BOOLEAN | false | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | β |