✂️ Omnimatte Composition
Swap a video's background with latent arithmetic — no mask required
- vae
- orig_video
- background_video
- new_background
- composed_video
OmnimatteComposition is the sneaky-cool final step of this pack. The previous nodes deleted something from your video; this one puts the subject back - but onto a brand new background. And it does it with no mask, no green screen, no per-frame compositing. Just subtraction and addition in latent space, which sounds like magic until you see the source code and realize it's a three-line trick.
How it works
The premise: if you have a video with your subject in it (the orig_video) and the same video with the subject removed (background_video, straight out of Object Removal), then subtracting one from the other in the right space leaves you with the subject layer on its own - the object and its effects, separated from the background it was filmed against. That subtraction is the "omnimatte" in the pack's name: a matte that carries the object's shadows and reflections with it, because they're baked into the difference.
The node encodes all three inputs with the custom LTX VAE, computes the difference in latent space, adds it to the latent of your new_background, and decodes. Mathematically: z_composed = z_new_background + (z_orig − z_background). The orig − background term is your free cutout; the + new_background term is the relocation. Latent-space compositing, done in a single pass, no mask anywhere in the equation.
The inputs that matter
vae- this one is a trap. It must be theVAEoutput fromOmnimatteLoader, because that's the custom VAE with theforward_compositionmethod. Plug in a generic VAE from elsewhere and the node has no method to call. The pack's own wiring does this right; if you rebuild the graph, don't "helpfully" swap the VAE.orig_video- the untouched original, with the subject.background_video- the cleaned version from Object Removal.new_background- the replacement scene. It's an IMAGE input, so it can be a single frame that broadcasts across the clip or a full background video; the node trims everything to the shortest frame count and aligns it to the VAE'sk*8+1frame requirement for you.
Output is a single composed_video (IMAGE sequence) - preview it, or send it to VHS_VideoCombine to render.
How to install it
Same pack, same install, done once:
cd ComfyUI/custom_nodes
git clone https://github.com/tpc2233/ComfyUI-TP-OmnimatteZero.git
pip install -r ComfyUI-TP-OmnimatteZero/requirements.txt
Restart, or use ComfyUI Manager and search "ComfyUI-TP-OmnimatteZero". No extra downloads here beyond the LTX model the Loader already fetched.
Where people get burned
- The VAE trap above. Genuinely the most common stumble - the node errors out with something that looks like a VAE mismatch, and the fix is "use the loader's VAE."
- Different frame counts. The node trims to the shortest of the three inputs, so feed them the same length or the ending will silently get chopped.
- The subject's effects can leak. Because the "cutout" carries the object's shadow and reflections along with it, compositing onto a dramatically different background can look off - the shadow that made sense on the old floor doesn't on the new one. That's not a bug; it's the omnimatte promise, and it's also the thing to remember when choosing a
new_background. - It's not a relight or a shadow-generator. The subject keeps its original lighting baked into the layer. Fine for "drop the actor onto a clean backdrop"; wrong tool for matching a subject into a completely new lighting setup.
The full loop, for context: Loader loads the engine, Mask Gen builds the total mask, Object Removal produces the clean background, and this node closes the circle by putting your subject on a different world. It's the rare "remove an object and relocate the subject" pipeline that fits in one graph.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| vae | VAE | — | |
| orig_video | IMAGE | — | |
| background_video | IMAGE | — | |
| new_background | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| composed_video | IMAGE | — |