Mouth Shape Compositor
The last mile of a lip-sync pipeline
- frames
- mouth_shapes
- mouth_sequence
- mask
- frames
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.png–H.pngplusX.pngin exactly this order. - mouth_sequence - a per-frame list of mouth indices, one per frame. This is a custom
MOUTH_SEQUENCEtype, 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, orscreen. 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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| frames | IMAGE | Video frames batch (B, H, W, C) | |
| mouth_shapes | IMAGE | 9 mouth shape images in order A-H, X (indices 0-8) | |
| mouth_sequence | MOUTH_SEQUENCE | Per-frame mouth shape indices | |
| position_x | INT | 0-4096–4096 | X position for mouth placement |
| position_y | INT | 0-4096–4096 | Y position for mouth placement |
| maskopt | MASK | Optional mask for mouth region blending | |
| blend_modeopt | COMBO | alpha | How to blend mouth onto frame |
| scaleopt | FLOAT | 1.000.1–10 | Scale factor for mouth shapes |
| featheropt | INT | 00–100 | Edge feathering in pixels |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| frames | IMAGE | — |