ComfyUI Node Runs on cloud

Mocha Embeds

Swap a character into a video with MoCha and Wan

By kijai·Created about a year ago·Updated 2 months ago· 6,651
Mocha Embeds
  • vae
  • input_video
  • mask
  • ref1
  • ref2
  • image_embeds
force_offloadtrue
tiled_vaefalse

MoCha is a "movie-grade talking character" model, and this node is where you set up a MoCha job inside Kijai's Wan wrapper. The use case: take an existing video, mask out a region, and have MoCha regenerate that region as a specific character you supply as reference images - driven by the motion in the source clip. It's character replacement / insertion with the performance carried over from the driving footage. The node bundles all of that into a single image_embeds object the Wan sampler renders from.

It's built on Wan 2.1, and like most of these it's compute-hungry - worth knowing before you download 27GB and then can't run it.

How it works

You hand MochaEmbeds four things that define the job: the driving input_video, a mask marking where the character goes, and one or two ref images of the character you want there. It encodes all of that through the Wan VAE into the latent conditioning MoCha needs, and returns it as WANVIDIMAGE_EMBEDS - the same embeds type Wan's own image-to-video path uses, so it drops straight into the standard sampler. The model then fills the masked region with your character, following the motion and framing of the source.

Two reference images (ref1 plus optional ref2) let you show the character from more than one angle, which helps identity hold up when the head turns.

The inputs and outputs that matter

  • input_video (IMAGE) - the driving footage, as a frame batch. Its motion is what gets carried onto the character.
  • mask (MASK) - where MoCha works. Everything outside the mask is left alone; everything inside becomes your character. Get this right and half the job is done.
  • ref1 (IMAGE, required) and ref2 (optional) - reference shots of the character.
  • vae (WANVAE) - the Wan VAE, required for the encode.
  • tiled_vae (default false) - turn this on if the VAE encode itself OOMs at higher resolutions; it trades a little speed for much lower peak VRAM.
  • force_offload (default true) - offloads to CPU between steps to save memory. Leave on unless you're tuning for speed with headroom to spare.

Output: image_embeds (WANVIDIMAGE_EMBEDS) → WanVideoSampler.

How to install it

ComfyUI Manager → search ComfyUI-WanVideoWrapper, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-WanVideoWrapper
pip install -r ComfyUI-WanVideoWrapper/requirements.txt

then restart. You need the MoCha weights plus a Wan model, VAE and text encoder. Here's the practical part learned the hard way by people on 5090s: the full MoCha model is ~27GB and will OOM even on 32GB cards. Grab Kijai's fp8 build instead - it lives at huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/tree/main/MoCha - or a GGUF quant. Reports have MoCha running on 16GB once you switch off the full-precision weights.

Common issues & troubleshooting

Out of memory no matter what. You're on the full 27GB checkpoint. Switch to the fp8 scaled build (link above) or a GGUF; that's the fix, not lowering resolution. This is the number-one MoCha complaint.

The replacement bleeds outside where you wanted it. Your mask is loose or feathered too far. MoCha only regenerates the masked region - tighten it, and make sure it tracks the subject across all frames rather than being a single static shape.

Identity drifts when the character turns. Feed ref2. One reference is a single viewpoint; a second angle gives MoCha something to hold onto through head rotation.

VAE encode itself crashes. Flip on tiled_vae. The encode of a full video batch is memory-heavy independent of the model; tiling caps that.

CategoryWanVideoWrapper

Inputs (7)

NameTypeDefaultDescription
vaeWANVAE
force_offloadBOOLEANtrue
input_videoIMAGEInput video to encode
maskMASKmask
ref1IMAGEImage to encode
ref2optIMAGEImage to encode
tiled_vaeoptBOOLEANfalseUse tiled VAE encoding for reduced memory use

Outputs (1)

NameTypeDescription
image_embedsWANVIDIMAGE_EMBEDS