Nodes/arkennemasis Nodes/arkennemasis Overlay Subject (cut-out onto a background)
ComfyUI Node

arkennemasis Overlay Subject (cut-out onto a background)

Standing a cut-out presenter in front of your background, your way

By Hishamahmer·Created about a month ago·Updated a day ago· 6
arkennemasis Overlay Subject (cut-out onto a background)
  • background
  • subject
  • subject_mask
  • images
  • placed_mask
  • report
canvas_width720
canvas_height1280
subject_scale0.70
offset_x0.25
offset_y0.00
anchor
background_fit
crop_to_subjecttrue
crop_box
crop_padding0.02
opacity1.00

ArkOverlaySubject is the compositing step in the avatar pipeline: it takes a masked subject - a presenter cut out of a generated clip - and stands them on a background at a chosen size and position. The pack calls it "the part a hosted avatar service does for you and never lets you adjust," and that's the honest pitch. A hosted presenter service hands you back a finished frame; this node gives you the controls a video editor would actually want.

The key design decision, and the one that separates it from a naive paste: the subject is cropped to its mask before it's scaled. So subject_scale is the fraction of the frame the subject fills, not the fraction of the whole source picture. If you scaled the whole picture, a presenter who occupies a small corner of their generated frame would end up small and off to one side no matter what you did. Cropping first makes scale mean what you think it means.

How it works

Wire in background (one frame is reused for every subject frame; a batch is used frame for frame), subject (the whole picture the subject was generated in), and subject_mask - which should come out of a refine node, not raw, because a raw segmentation boils along the edge.

The inputs that matter:

  • canvas_width / canvas_height - 720×1280 by default, the vertical format short-form platforms want.
  • subject_scale - subject height as a fraction of the canvas, measured on the cropped subject. Above 1.0 the subject is taller than the frame and gets cropped by it.
  • anchor - where the subject sits before offsets. bottom stands them on the lower edge, which is how a presenter is framed.
  • offset_x / offset_y - shifts as fractions of the canvas from the anchor. The defaults put a presenter slightly right, the classic talking-head spot.
  • background_fit - cover (fill, crop overflow), contain (fit inside, pad), or stretch (distort).

Worth knowing: crop_box defaults to one box for the whole clip, which holds the framing still (locked off). A box per frame tracks tighter and makes the subject breathe - use it when the subject moves around in their source clip. crop_padding (0.02) adds margin around the mask box so a feathered edge isn't clipped by its own box. opacity fades the subject in, if you want a ghost rather than a solid.

Outputs: images (the composited frames), placed_mask (where the subject actually landed - useful if anything downstream needs to know), and report.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/Hishamahmer/comfyui-arkennemasis
pip install replicate httpx

Restart ComfyUI. No models or keys - it's a compositor.

Troubleshooting

  • Subject tiny or huge regardless of subject_scale: crop_to_subject (on by default) is what makes scale mean subject-scale. Turn it off and subject_scale means the whole source picture's fraction of the frame, "which is almost never what you want" - the tooltip's words, and it's right.
  • Edgy, boiling cut-out: refine the mask first (ArkMaskRefine) - that's the documented order.
  • Feathered edge looks clipped: raise crop_padding.
Categoryarkennemasis/Utility

Inputs (14)

NameTypeDefaultDescription
backgroundIMAGEThe backdrop. One frame is reused for every subject frame; a batch is used frame for frame.
subjectIMAGEThe subject's frames — the whole picture it was generated in. Cropping happens here.
subject_maskMASKWhite where the subject is. Refine it before this: a raw segmentation boils along the edge.
canvas_widthINT72064–8192Output width. 720x1280 is the vertical format the short-form platforms want.
canvas_heightINT128064–8192Output height.
subject_scaleFLOAT0.700.05–3The subject's height as a fraction of the canvas height, measured on the cropped subject. Above 1.0 the subject is taller than the frame and gets cropped by it.
offset_xFLOAT0.25-1.5–1.5Sideways shift as a fraction of canvas width, from the centre. Positive moves right.
offset_yFLOAT0.00-1.5–1.5Vertical shift as a fraction of canvas height, from the anchor. Positive moves down.
anchorCOMBOWhere the subject sits before the offsets. `bottom` stands them on the lower edge, which is how a presenter is framed.
background_fitCOMBOHow the backdrop fills the canvas when its shape differs.
crop_to_subjectoptBOOLEANtrueCrop to the mask before scaling. OFF makes `subject_scale` mean the fraction of the frame the whole SOURCE PICTURE fills, which is almost never what you want.
crop_boxoptCOMBOOne box for the clip holds the framing still. A box per frame tracks tighter and makes the subject breathe.
crop_paddingoptFLOAT0.020–0.5Extra margin around the mask box, as a fraction of its size, so a feathered edge is not clipped by its own box.
opacityoptFLOAT1.000–1Subject opacity. Below 1.0 the background shows through.

Outputs (3)

NameTypeDescription
imagesIMAGE
placed_maskMASK
reportSTRING