Nodes/ComfyUI-YarvixPA/πŸš€ Frame Calculator (Audio)
ComfyUI Node

πŸš€ Frame Calculator (Audio)

Frames = audio length Γ— fps, without the mental math

By YarvixPAΒ·Created about a year agoΒ·Updated 6 months agoΒ· 14
πŸš€ Frame Calculator (Audio)
  • audio
  • frame_rate
  • frame_rate_int
  • frames_number
  • audio_duration
β—„fps30.0β–Ί

Animate an image to a song, and sooner or later you need to know one number: how many frames does this audio need at 30fps? Video models are brutally picky about that count - too few frames and the clip truncates, too many and you're paying VRAM for silence. This node computes the exact frame count from an actual audio input, so you never have to eyeball a 3.17-second clip again.

It's the audio-aware sibling of the pack's FrameCalculatorVideo. Feed it an AUDIO and an fps, and it reads the duration straight off the waveform, does the multiplication, and hands you the numbers - plus a nice summary right in the node's UI.

How it works

The node expects a real AUDIO dict - the kind a Load Audio node produces - with a waveform tensor and a sample_rate. It divides the sample count by the sample rate to get the exact duration in seconds, then:

  • frame_rate - the fps you set (float, e.g. 30.0 or 29.97).
  • frame_rate_int - the same value rounded to an int (30).
  • frames_number - round(fps Γ— duration), the number you actually feed to your video-model's frame count.
  • audio_duration - the clip length as a HH:MM:SS string, for the label.

It's an output node, so the summary (Frame rate: 30 fps … Number of frames: 42 …) renders inside the node after execution.

Inputs

  • audio - from an audio-loading node. Must be a proper AUDIO dict.
  • fps - 1.0 to 480.0, default 30.0. Set it to match your video model's real output rate.

Outputs: frame_rate, frame_rate_int, frames_number, audio_duration.

Install

ComfyUI Manager (search "YarvixPA") or

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

restart. Under ComfyUI-YarvixPA/Utils/Calculators.

Two honest notes

It validates its input - if you wire in something that isn't an audio dict (a path, a tensor, nothing), it raises a clear error rather than silently returning nonsense. That's a feature; don't fight it by bypassing the type. And remember the frame count is rounded, which is the right behavior for video models - they want a whole number - but it means a 1.4-second clip at 30fps is 42 frames, and if the model needs a multiple of something, round up yourself. Where this node shines is music-video and lipsync graphs where the audio is the source of truth; wire frames_number straight into the model's length parameter and the sync just works.

CategoryComfyUI-YarvixPA/Utils/Calculators

Inputs (2)

NameTypeDefaultDescription
fpsFLOAT30.01–480β€”
audioAUDIOβ€”

Outputs (4)

NameTypeDescription
frame_rateFLOATβ€”
frame_rate_intINTβ€”
frames_numberINTβ€”
audio_durationSTRINGβ€”