Trim to Shortest
Stop your video and audio drifting out of sync
- images
- audio
- images
- audio
Audio/video sync is the most boring failure mode in video generation and it will absolutely ruin your day. You generate 81 frames at 16fps - that's 5.06 seconds of video. Your audio track is 4.8 seconds. One of them has to give, or your save node complains and your lipsync looks like a badly-dubbed movie. Trim to Shortest is the node that decides which one loses, and it does it on a frame-exact basis.
What it does
The node takes an image batch (your video frames) and an audio track, and aligns their durations by trimming the longer one down to match the shorter. You pick the policy with trim_mode:
shortest- trim both to the shorter of the two, so nothing is wasted and they end together.video_to_audio- trim the video to the audio's length. The one you want when the audio is the boss (a music track, a voiceover you can't cut).audio_to_video- trim the audio to the video's length. For when the video is the boss (a generated clip you want kept intact).
fps tells the node how to convert between frames and seconds - get this wrong and the trim lands on the wrong frame, so make sure it matches the fps your video was generated at (16 for typical WAN workflows, 25 if you're working in a broadcast-style pipeline).
The two inputs - images and audio - are both optional, which is more useful than it sounds: you can run the node to trim just a video against nothing else, or just an audio track, and it'll pass the untouched stream through.
Why you'll want it
It slots in right before the Save Video / compile stage of a video pipeline. Generate frames, load your audio, trim the mismatch, then hand both to the save node - no more "audio and video length mismatch" errors at the last step. It also plays nicely with the Eclipse audio loop tools (Loop Calculator, Audio Loop Align Silence), which exist to solve the same family of length-matching problems for looped and music-driven content.
The honest take: this is a small node with one job, and it's the kind of thing you don't notice until it saves you from a 20-minute debug of a sync error that turns out to be a 0.2-second length mismatch.
Outputs
Both images and audio come out, trimmed or untouched depending on your mode and which side was shorter. Wire them straight into Save Video or Preview Video.
Install it
Ships in ComfyUI_Eclipse. ComfyUI Manager → search "Eclipse" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI_Eclipse
Pack deps are the usual (opencv-python, pilgram, PyYAML, aiohttp; portable installs may need pip install -r custom_nodes/ComfyUI_Eclipse/requirements.txt). It's under Eclipse → Video.
Gotchas
fps mismatch is the #1 silent killer - the trim math is all frame counts, and if the fps you enter doesn't match how the video was actually generated, "trim to audio" will land a few frames off the end you intended. Also note the name: this node cuts, it never stretches or pads. If you need the video to fill audio that's longer, that's a loop/keep-calculator job, not this one. And if both inputs are connected and one is much shorter than expected, double-check the upstream batch - a video batch that collapsed to a single frame will "win" the trim and silently eat your whole video.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| fps | FLOAT | 16.001–240 | Target frame rate (frames per second) of the video. |
| trim_mode | COMBO | shortest | How to align durations: shortest (trim both), video_to_audio (trim video), audio_to_video (trim audio). |
| imagesopt | IMAGE | Input video frames (image batch). | |
| audioopt | AUDIO | Input audio track. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | Trimmed or original video frames. |
| audio | AUDIO | Trimmed or original audio track. |