Nodes/ComfyUI_Fill-Nodes/FL Audio Frame Calculator
ComfyUI Node

FL Audio Frame Calculator

Turn an audio clip and an FPS into the exact frame count you need

By filliptm·Created 3 years ago·Updated a day ago· 630
FL Audio Frame Calculator
  • audio
  • frame_count
fps24.0

If you've ever generated a video to fit a piece of audio and ended up with a clip that runs out a beat early or trails on past the last note, you know the problem this solves. Getting frame count right is just arithmetic - duration times FPS - but doing it in your head every time you tweak the audio or the frame rate is exactly the kind of small friction that trips people up. FL_AudioFrameCalculator does that one sum so you don't have to eyeball it.

Feed it an audio clip and your target FPS, and it returns the integer number of frames needed to cover the audio's full duration. That INT then drives whatever video node needs a frame budget, so your render length is tied to the actual audio instead of a guessed constant.

How it works

It reads the duration of the AUDIO input, multiplies by your FPS, and rounds up - ceil(duration × fps). The ceiling matters: it guarantees the frame count covers the whole clip rather than cutting off a fraction of a second at the end. Round down and your video would stop just short of the audio finishing; rounding up means at worst you have one extra frame of headroom, which is the safe direction to err.

The inputs and outputs that matter

Two inputs, both required:

  • audio (AUDIO) - the clip whose length you're matching. Straight off a Load Audio node, or the output of FL_Audio_Crop if you trimmed to a segment first.
  • fps (FLOAT, default 24, range 1–120) - the frame rate you intend to render at. This has to match the FPS you actually use downstream, or the math is right but the sync is wrong.

Output is a single frame_count (INT) - wire it into the frame-count / length input of your video generation node, a batch sizer, or a WAN sampler's frame parameter.

When you'd reach for it

Any audio-synced video build. Music videos, where you want the clip to end exactly on the last beat. Lip-sync and talking-head work, where the frame count has to cover the whole spoken line. Audio-reactive visual loops, where the effect nodes expect a frame sequence sized to the track. The clean pattern is: crop the audio to your segment, calculate the frame count here, then hand that number to the generator - so the whole chain flexes automatically when you change the audio.

Installing it

ComfyUI Manager → search ComfyUI_Fill-Nodes → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes

then restart. It's part of filliptm's Fill-Nodes pack; the audio nodes bring in standard audio libraries on first install, so the initial dependency pull is on the heavier side.

Common issues & troubleshooting

Match this FPS to your render FPS. The single most common mistake: calculate at 24 fps here, then export at 30. The count will be internally correct but your video won't line up with the audio. Keep the two numbers identical.

Expect at most one extra frame. Because it rounds up, the count can be one frame longer than a perfect fit. That's intentional and harmless - better a frame of tail than a clipped ending.

Fractional FPS is allowed. The input is a FLOAT, so 23.976 or similar is fine if you're matching a specific source rate. Just carry that same value everywhere downstream.

Category🏵️Fill Nodes/Audio

Inputs (2)

NameTypeDefaultDescription
audioAUDIO
fpsFLOAT24.01–120

Outputs (1)

NameTypeDescription
frame_countINT