Nodes/TrentNodes/Mouth Shape Compositor
ComfyUI Node

Mouth Shape Compositor

The last mile of a lip-sync pipeline

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Mouth Shape Compositor
  • frames
  • mouth_shapes
  • mouth_sequence
  • mask
  • frames
position_x0
position_y0
blend_modealpha
scale1.00
feather0

Animation lip-sync, done the classic way, is a lookup table: you've got a set of mouth drawings (the standard nine positions, A through H plus X for silence), you know which position each frame should show, and you stamp the right drawing onto each frame. Mouth Shape Compositor is that last step - the compositor that takes your frames, your nine mouth images, and a per-frame index sequence, and pastes the mouths on at a position you set.

It's the "basic" compositor in the pack's Trent/LipSync family - the README positions it for static characters or simple animations, while the (Tracked) variant follows a moving mouth with point or mask tracking. If your character's head doesn't move, this one is all you need, and it's the one with the fewest moving parts.

Inputs

  • frames - your video frame batch, (B, H, W, C).
  • mouth_shapes - the nine mouth images, in order A–H then X, indices 0–8. The node validates you've got at least nine; the pack's Mouth Shape Loader is the companion that loads a folder of A.pngH.png plus X.png in exactly this order.
  • mouth_sequence - a per-frame list of mouth indices, one per frame. This is a custom MOUTH_SEQUENCE type, produced upstream by the pack's Phoneme To Mouth Shapes node - you don't type these by hand.
  • position_x / position_y - where the mouth goes, in pixels. This is the fixed-position part; you set it once (or wire it from a computed value) and every frame stamps at the same spot.
  • mask - optional, for blending the mouth region.
  • blend_mode - alpha (default), replace, multiply, or screen. Alpha is the right choice when your mouth shapes carry transparency.
  • scale - 0.1×–10×, for sizing the mouths to your character. Default 1.
  • feather - edge feathering in pixels, for softening the stamp seam.

One output: frames, the composited batch.

How the pipeline assembles

The full flow the README walks through: Audio To Phonemes (Vosk speech recognition → timestamped phonemes) → Phoneme To Mouth Shapes (phonemes → the A–H+X indices) → Mouth Shape Loader (your nine PNGs) → this node to stamp them on. It's a real, working animation pipeline that never touches a generative model for the mouth itself - classic 2D animation technique, just driven by speech recognition instead of a human animator.

Install

Part of TrentNodes:

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

Restart, look under Trent/LipSync. The full pack's requirements include vosk for the speech side; this compositor node itself is just torch tensor ops, so if you only use this node you don't need Vosk at all.

Gotchas

The big one is alignment: the mouth shapes and the character must actually line up, and since this node is fixed-position, any head movement means the mouth floats off. That's what the (Tracked) variant is for - use this one only when the face is static. Second, position_x/y defaults to 0,0, which is the top-left corner; a mouth at 0,0 is invisible in most frames, so set the position or you'll "render" fine-looking nothing. Third, index order is sacred: A–H, X. Load your shapes once through the Mouth Shape Loader and you won't have to think about it again, but hand-rolling the batch is where off-by-one mouth positions (and silent characters) come from.

CategoryTrent/LipSync

Inputs (9)

NameTypeDefaultDescription
framesIMAGEVideo frames batch (B, H, W, C)
mouth_shapesIMAGE9 mouth shape images in order A-H, X (indices 0-8)
mouth_sequenceMOUTH_SEQUENCEPer-frame mouth shape indices
position_xINT0-4096–4096X position for mouth placement
position_yINT0-4096–4096Y position for mouth placement
maskoptMASKOptional mask for mouth region blending
blend_modeoptCOMBOalphaHow to blend mouth onto frame
scaleoptFLOAT1.000.1–10Scale factor for mouth shapes
featheroptINT00–100Edge feathering in pixels

Outputs (1)

NameTypeDescription
framesIMAGE