Nodes/ComfyUI-LivePortraitKJ/LivePortrait Composite
ComfyUI Node Runs on cloud

LivePortrait Composite

Putting the animated head back on the body

By kijai·Created 2 years ago·Updated 2 years ago· 2,199
LivePortrait Composite
  • source_image
  • cropped_image
  • liveportrait_out
  • mask
  • full_images
  • mask

LivePortrait Process gives you an animated face on a plain background. That's not a video yet - that's a talking head sticker. LivePortraitComposite is the node that makes it a video by warping the animated head back onto the full source frame and blending it in. You can't ship a LivePortrait result without this node, and it's more subtle than it looks.

The node's inputs tell the whole story: source_image (the original frames), cropped_image (the animated face from Process), and liveportrait_out (the LP_OUT from Process). If you've tried to wire the raw animated crop straight into a VAE/VideoCombine and gotten a floating head with a black background, this is the missing piece.

How the paste-back works

The composite reads the crop transform (M_c2o) that the cropper stored in the crop info - the inverse of the crop it made earlier - and uses it to warp the animated head back into place on the full frame. Then it blends using a mask. By default that mask is the pack's built-in mask_template.png, a soft face-shaped matte. You can override it with your own mask input (2D or 3D, per-frame) if you want tighter or looser blending around the jaw or hairline.

Two details worth knowing:

  • It respects the Process node's mismatch_method. If the driving video outnumbers the source frames, the composite picks the matching source frame the same way Process did - cut does a straight frame-by-frame match, the others repeat/cycle. If they disagree, you get weird source-face jumps, so don't mix them up.
  • Frames where Process found no face are handled gracefully: the composite outputs the original source frame for those, with a zero mask, instead of a black square. That's the difference between "video with a glitch" and "video where the head occasionally freezes."

Outputs

  • full_images - the composited frames, ready for a VAE encode or VideoCombine.
  • mask - the per-frame blend mask it used, which is handy if you want to do your own post-blend (feather it, feed it to an inpaint pass, whatever).

When you'd change things

Honestly, for a first run, wire it up and leave it. The default template mask is well-tuned. You'll reach for the mask override when the blend shows a hard edge around the jaw (tighten it), or when the source has hair over the face and you want the composite to respect it. And if your output looks smeared or shifted, double-check that the crop info going into Process actually came from the same cropper that produced the source crop - feeding mismatched crop info here produces exactly that kind of glitch.

One real quirk: on Apple silicon (MPS), the node deliberately falls back to CPU because the affine transform returns NaNs on MPS. It's slow but correct - that's a known workaround in the code, not something you need to fix.

Common failure to know about: if the whole output is the source video with a frozen face region, your driving frames all failed detection. Fix the detection (better detector, more stable driver), not the composite - it's doing exactly what it's told.

CategoryLivePortrait

Inputs (4)

NameTypeDefaultDescription
source_imageIMAGE
cropped_imageIMAGE
liveportrait_outLP_OUT
maskoptMASK

Outputs (2)

NameTypeDescription
full_imagesIMAGE
maskMASK