Nodes/TKNodes/Resample Audio for new FPS
ComfyUI Node

Resample Audio for new FPS

The node that stops your video/audio sync from falling apart in V2V

By trashkollector·Created about a year ago·Updated a day ago· 1
Resample Audio for new FPS
  • audio
  • video
  • matched_audio
  • exact_duration_seconds
video_fps16.00

Ever rendered a video-to-video pass and ended up with audio that's a beat ahead, or gets chopped mid-word? That's the mismatch this node exists for. Resample Audio for new FPS takes your original master audio plus your freshly generated video tensor, and makes the audio exactly as long as the video's timeline wants it to be. The README's example is the classic case: a 30fps source clip with audio, but you're generating into a 24fps LTX pipeline - the durations stop agreeing, and the audio drifts or gets truncated when you combine.

Despite the name, it does not touch the audio's sample rate. What it actually resamples is duration: it figures out how many seconds your generated video occupies at video_fps, then trims the audio if it's too long or pads it with silence if it's too short, so the two match to the sample.

How it works

Three inputs: the AUDIO master track, the IMAGE tensor of your generated video, and video_fps (a FLOAT, default 16.0 - the tooltip reminds you that LTX-ish pipelines often sit at 16fps, though 24 and 25 are common too).

The node counts the frames in the video tensor, divides by video_fps to get the exact container duration in seconds, then converts that to a sample count at the audio's own sample rate:

  • Audio longer than the video → trimmed at the end (so a combiner doesn't force-chop it mid-word).
  • Audio shorter → silence-padded to fill the gap.
  • Audio dead on → passed through untouched.

The IMAGE in is just used as a measuring stick - it passes through unchanged (the node's video-frame math is effectively a no-op on the tensor, which is fine, because the part you actually want is the duration). You get two outputs: matched_audio (the AUDIO you wire into your combiner) and exact_duration_seconds (the float proving what the node computed, handy for diagnostics).

Why you'd reach for it

If you've hit VHS-style combiner truncation - where the combine step cuts your audio at the video's shorter boundary - this is the standard fix in this pack. It's primarily a V2V tool, as the code comment says: your source video and your target video run at different FPS, and the audio was attached to the source. Slip this node between the generated video and the final combine and the lengths stop fighting.

Installing it

This is part of trashkollector/TKNodes ("ComfyUI Handy Nodes"). Install through ComfyUI Manager by searching "Handy Nodes", or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/trashkollector/TKNodes

Restart ComfyUI. It needs nothing beyond the pack's standard stack - torchaudio, pydub, and FFmpeg on your PATH if you're touching MP3/compressed audio anywhere in the chain.

Common issues

The usual gotcha is feeding it the wrong video_fps - if you tell it 16 but your video is actually 24, it'll pad/trim to the wrong duration and you'll be less synced than before. Get the FPS from your video loader or metadata node, don't guess. And remember: it aligns length, not pitch or timing offset. If your audio is off by a fixed half-second at the start, this node won't fix that - that's a trim or offset problem, not a duration problem.

CategoryTKNodes

Inputs (3)

NameTypeDefaultDescription
audioAUDIOOriginal master audio
videoIMAGEYour newly generated video tensor
video_fpsFLOAT16.001–60The FPS of your generated video (e.g., 16.0)

Outputs (2)

NameTypeDescription
matched_audioAUDIO
exact_duration_secondsFLOAT