Nodes/comfyui-sequential-batcher/AudioDurationCalculator
ComfyUI Node

AudioDurationCalculator

How long is this audio, exactly? Ask the waveform, not a guess

By Meisoftcoltd·Created 7 months ago·Updated 18 days ago· 3
AudioDurationCalculator
  • audio
  • duration_seconds
  • log

Synchronizing generated video to an audio track comes down to one number you can't eyeball: the exact duration of that track in seconds. If your video generator needs a frame count and you've only got an audio file, you have to know how many seconds it runs. AudioDurationCalculator does the boring, reliable thing - it reads the audio's sample count and sample rate and returns the real duration.

The reason to use this instead of just reading the filename or trusting a file listing is that audio duration is a math problem, not a metadata field. A waveform at 44,100 Hz with 220,500 samples is exactly 5 seconds - the node divides samples by sample rate and gets the truth. No container metadata guessing, no rounding to the nearest second.

How it works and what it gives you

Feed it an AUDIO object (the standard ComfyUI audio dict - waveform + sample_rate). It computes samples / sample_rate and returns:

  • duration_seconds (FLOAT) - the precise length. This is the wire you actually care about.
  • log (STRING) - a status line showing the math (220500 samples @ 44100Hz).

It's defensive about bad input: not a valid audio dict, or missing waveform, and it returns 0.0 rather than crashing. That's the right behavior for a node that sits inside a loop where one bad cycle shouldn't kill the whole run.

Where it fits

Inside this pack, it's a supporting player in the audio-sync flow: you take the duration, multiply by your target FPS, and you've got a frame count that lines up with the audio. Outside the pack it's just a useful measurement node - measuring an audio clip before deciding how many frames a VHS or LTX generation should produce.

Honest note: it's a two-line calculation and you could do it with any generic math node that can reach into an audio dict. But not every math node handles the "audio is a dict, not a number" part gracefully, and this one is already on your graph if you've installed the pack. For the cost of zero setup, it's the one you'd grab.

Install

ComfyUI Manager → search "comfyui-sequential-batcher", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Meisoftcoltd/comfyui-sequential-batcher

Restart ComfyUI. No models, no extra system dependencies for this node alone - the pack's FFmpeg requirement only bites when a video analyzer needs to extract or remux audio. And the usual house rule applies: launch ComfyUI without --highvram so the loop's memory management stays functional.

Category🔁 Sequential Batcher/Tools

Inputs (1)

NameTypeDefaultDescription
audioAUDIO

Outputs (2)

NameTypeDescription
duration_secondsFLOAT
logSTRING