Nodes/ComfyUI-VideoBasicLatentSync/VideoBasic LatentSync Length Adjuster
ComfyUI Node

VideoBasic LatentSync Length Adjuster

The unglamorous node that makes LatentSync line up

By jax-explorer·Created about a year ago·Updated about a year ago· 0
VideoBasic LatentSync Length Adjuster
    • video_path
    video_path
    audio_path
    modenormal
    fps25.00
    silent_padding_sec0.5

    Somewhere between the video loader and the LatentSync node, your clip and your audio have to agree on how long they are. LatentSync won't sort that out for you. This node is the length-matching step, and it's boring on purpose - it's the half of the pack you reach for when your 3-second loop needs to cover a 10-second voice line and you can't be bothered to hand-edit frames.

    Here's the context. ByteDance's LatentSync 1.5 wants a clean, frontal, ~25fps talking head whose duration roughly matches the audio you're syncing it to. Feed it a video that's half the length of the audio and the sync drifts; feed it a clip that's longer and you're burning VRAM on frames the model can't use. LatentSync is also the dedicated audio-driven lip-sync approach - the one that only rewrites the mouth region of a real video rather than generating a head from scratch - so getting the input length right is what keeps it usable. This node is the guardrail for that.

    How it works

    It's a small ffmpeg pipeline with a torchaudio reading on top. The node pulls the frames out of your video, loads your audio, then decides what to do based on the mode:

    • normal - pads the audio with silent_padding_sec of silence, then trims the video down to match the padded length. If the video is shorter than the audio, it trims the audio instead. This is the safe default.
    • pingpong - when the audio runs longer than the video, it plays the frames forward and then reversed, boomerang-style, until they cover the audio. Great for loops that should feel continuous rather than jarringly restart.
    • loop_to_audio - plain forward loop of the frames to fill the audio duration, with the same silent padding.

    Either way it re-encodes everything as H.264 + AAC at your chosen fps and writes a timestamped mp4 into the pack's outputs/ folder.

    The inputs that matter

    • video_path / audio_path - note that the audio is required even though this node never looks at the mouth. It's the length reference; the node measures the clip against it.
    • mode - the three above: normal, pingpong, loop_to_audio.
    • fps - default 25, which is what LatentSync 1.5 is tuned for. If you leave it at 25 you get a video LatentSync already likes.
    • silent_padding_sec - default 0.5. Gives the model a beat of silence to chew on; on short clips this padding is what stops the sync from feeling rushed.

    The node returns a single video_path STRING, which is exactly what the sibling VideoBasicLatentSyncNode wants on its own video_path input. That's the whole wiring: loader → this node → LatentSync node.

    Installing and the snags

    It ships in the same pack, so one install covers both: ComfyUI Manager search "ComfyUI-VideoBasicLatentSync", or git clone https://github.com/jax-explorer/ComfyUI-VideoBasicLatentSync into ComfyUI/custom_nodes, then pip install -r requirements.txt. FFmpeg is non-negotiable here - this node is essentially a GUI for ffmpeg, and the pack hard-fails on load if it's missing from PATH.

    A few honest caveats. The re-encode is a full generation of compression, so don't use this on a master you plan to grade - it's a sync-prep step, not a delivery format. The pingpong mode drops the endpoint frames so the reversal doesn't flash a duplicate, which is the right call but means you lose the very last frame. And the repo's README is a verbatim copy of the upstream wrapper's, install instructions included, so it tells you to clone the wrong repository - clone the jax-explorer one. If your video and audio already match in length, you can skip this node entirely; the LatentSync node accepts a plain path. You only need this when the lengths don't line up, and then it saves you from what would otherwise be a fiddly session with the VHS VideoCombine node.

    CategoryLatentSyncNode

    Inputs (5)

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

    Outputs (1)

    NameTypeDescription
    video_pathSTRING