ComfyUI Node

CoverVideo

The paste-back node that finishes every AniPortrait face-swap

By chaojie·Created 2 years ago·Updated 2 years ago· 251
CoverVideo
  • bgimage
  • coverimage
  • box
  • IMAGE

CoverVideo is the second half of the crop-and-paste loop that makes AniPortrait workflows feel like a pipeline instead of a party trick. Where Box2Video crops a region out, CoverVideo puts it back: it takes a background image, a cover image, and a BOX, and blits the cover onto the background at the box's top-left corner.

The mental model is the face-swap round trip. You crop your portrait tight with a mask or box, feed the crop to AniPortraitRun so it animates just the face, and then use the box you kept to stick the animated result back onto the original background frame. CoverVideo is that final stamp. The source is about as direct as code gets: bg[y1:y1+h, x1:x1+w] = cover, where w and h come from the cover image's own dimensions.

The inputs that matter

  • bgimage - the background you're pasting onto (usually a frame from the original video).
  • coverimage - the generated face/portrait video frame being pasted in.
  • box - [x1, y1, x2, y2], the top-left anchor is what matters here; the cover's own size determines the paste extent, so the box's width and height should match the cover's resolution or you'll get a slightly off stamp.

Output is a single IMAGE: the background with the cover pasted over it.

Two things the README won't tell you

First, this is a hard paste, no alpha. The cover lands fully opaque on top of the background. That's fine when your animated face was generated on a matching background, but if there's a visible seam you're expected to handle blending elsewhere in the graph (a mask composite after this node, or animating against a clean background in the first place). Second, there's no resize - the cover is stamped at its native size, which is exactly why the standard workflow reuses the box from the crop that made it. That symmetry is the intended design, and fighting it (hand-typing coordinates) is how you end up with a face pasted into the middle of someone's chest.

Installing it

It ships in chaojie/ComfyUI-AniPortrait, so install the pack as usual:

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

Like the other helper nodes, CoverVideo itself touches no models and no GPU, but the pack's module imports its whole dependency stack at load time - so that requirements.txt is still non-negotiable before the node appears. If you're assembling a crop → animate → paste-back chain, this is the closing bracket.

CategoryAniPortrait

Inputs (3)

NameTypeDefaultDescription
bgimageIMAGE
coverimageIMAGE
boxBOX

Outputs (1)

NameTypeDescription
IMAGEIMAGE