Nodes/ComfyUI-ListHelper/Audio to Frame Count
ComfyUI Node

Audio to Frame Count

Know exactly how many frames an audio file needs before you render

By dseditor·Created about a year ago·Updated 7 months ago· 75
Audio to Frame Count
  • audio
  • frames
fps25.000

If you've ever tried to make a talking-head or "digital human" video, you know the pain this node exists to solve: the audio is 13.7 seconds long, but your image-to-video model needs a frame count, and if you guess wrong the lipsync drifts, the video ends early, or you're looping frames at the wrong speed. AudioToFrameCount is a one-trick node that does the math for you - feed it audio, tell it your fps, and it returns the exact integer number of frames that audio occupies. No guesswork, no calculator, no "eh, close enough."

How it works

The mechanism is embarrassingly simple, which is exactly why it's reliable. ComfyUI's AUDIO type is a dict holding a waveform tensor plus its sample_rate. The node reads the total number of samples, divides by the sample rate to get the duration in seconds, then multiplies by your fps:

frames = int((total_samples / sample_rate) * fps)

That int() cast is the whole thing. It floors, so a 13.7s file at 25fps gives you exactly 342 frames. Wire that number into whatever node needs a frame count and your video will land right at the end of the audio instead of a second short.

Inputs and output

  • audio - any AUDIO output. Load a file with ComfyUI's audio-loader nodes or split one with the pack's own Audio Split to List node first.
  • fps - frames per second of your target video, default 25. Set it to match your video node's fps or the last frame will be held or dropped.

The single output, frames (INT), plugs straight into a repeat-image node, a video combiner, or anything else that takes a frame count. ComfyUI lets you wire an INT into most number inputs directly.

Installing it

It's part of the ComfyUI-ListHelper pack, so you get this one node bundled with twenty-ish siblings:

cd ComfyUI/custom_nodes
git clone https://github.com/dseditor/ComfyUI-ListHelper

Restart ComfyUI and look under ListHelper/Audio. ComfyUI Manager works too - search "ComfyUI-ListHelper". No models, no API key, no extra Python packages beyond what ships with the pack.

When you'd actually use it

The canonical workflow the author built this for: generate or load a voiceover, split it into timed segments, render each segment's frames at the exact count, then stitch. If you pair it with the pack's Audio Split to List node, you get a clean pipeline where every rendered clip is guaranteed to match its audio chunk. It also quietly saves you from a classic failure mode - holding a single image across an audio track via a repeat node, where you'd otherwise have to hardcode the count and re-tweak it every time you edit the audio.

The only real gotcha is remembering that it floors: at 25fps a 0.04s rounding error can leave you one frame short over a long track. If your combiner needs exact length, round up by adding a frame or two - or run FrameMatch afterwards to pad to the exact count you need.

CategoryListHelper/Audio

Inputs (2)

NameTypeDefaultDescription
audioAUDIO
fpsFLOAT25.000

Outputs (1)

NameTypeDescription
framesINT