Nodes/ComfyUI-LatentSyncWrapper/Video Length Adjuster
ComfyUI Node Runs on cloud

Video Length Adjuster

When the video runs out before the audio does — the lip-sync length fixer

By ShmuelRonen·Created 2 years ago·Updated 12 months ago· 958
Video Length Adjuster
  • images
  • audio
  • images
  • audio
modenormal
fps25.00
silent_padding_sec0.5

Lip-sync has a dirty secret nobody puts on the box: the video and the audio have to be exactly the same length, or the model's mouth finishes its sentence early and then drifts. This small helper ships in the same pack as the LatentSync1.6 Node precisely to fix that mismatch, and it sits right before it in the workflow: frames and audio in, matching-length frames and audio out.

It's a boring node, and that's the point. You use it when your clip is shorter than your audio - say you have ten seconds of someone looking at the camera and a thirty-second voiceover - or when the clip overruns the audio and the tail of the video is just dead air. It solves both directions and gives you a couple of ways to stretch footage, which matters more than you'd think for getting decent lip-sync instead of a mouth that finishes talking into a frozen face.

How it works

It's pure frame math, no model involved. Given the IMAGE batch and AUDIO, it picks one of three modes, then pads the audio with silence and trims or duplicates frames to hit the target duration at whatever fps you tell it. That's the whole mechanism - cheap, deterministic, and instant.

The three modes

  • normal - the conservative one. Adds silent_padding_sec of silence to the audio, then trims the video to match (or trims the audio back if the video is shorter). Use this when your take is close to the right length and you just need them to line up.
  • loop_to_audio - pads the audio, then keeps repeating the clip until it covers the whole thing. Good for holding a static or slowly moving shot under a long voiceover.
  • pingpong - loops the clip forward, then reversed, then forward. Stretches a short clip to a long audio with way less obvious "this is on repeat" energy than a plain loop, because the motion reverses instead of hard-cutting back to frame one.

Inputs that matter

  • images / audio - the same streams you're about to feed the LatentSync node.
  • mode - the three choices above; default normal.
  • fps (default 25) - keep it at 25, since LatentSync converts everything to 25 fps anyway. If you set it wrong, the frame count math comes out off and you're back to mismatched lengths.
  • silent_padding_sec (default 0.5, range 0.1–3.0) - the little tail of silence added so the last syllable doesn't get chopped off. Bump it if you keep losing final consonants.

Both images and audio pass through, now matched, ready to plug straight into LatentSyncNode's inputs.

Install and gotchas

It's not a separate install - it ships in the ComfyUI-LatentSyncWrapper pack, so installing that gets you this node too (Manager, search "ComfyUI-LatentSyncWrapper", or clone the repo and pip install -r requirements.txt). It has no extra dependencies of its own; the pack's heavy requirements are all for the lip-sync node.

The main trap is expecting magic. normal mode doesn't invent frames - if your clip is far shorter than the audio, it truncates the audio to fit rather than stretching the video, which is why the loop modes exist. And pingpong works fine for subtle movement, but a face that's talking mid-gesture will look odd played backward; that's what loop_to_audio is for. If the mouth still ends early after running this, check that your fps matches reality before blaming the adjuster.

CategoryLatentSyncNode

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
audioAUDIO
modeCOMBOnormal3 options: normal, pingpong, loop_to_audio
fpsFLOAT25.001–120
silent_padding_secFLOAT0.50.1–3

Outputs (2)

NameTypeDescription
imagesIMAGE
audioAUDIO