Nodes/afloy_audio_tools/Afloy Audio Duration
ComfyUI Node

Afloy Audio Duration

Sync audio to frames without a calculator

By afloy011-spec·Created 5 months ago·Updated 2 months ago· 6
Afloy Audio Duration
  • audio
  • duration_sec
  • duration_sec_int
  • frames
  • timecode
  • sample_rate
  • channels
fps24.000

Video models output frames, not finished videos - and none of them output audio. The moment you want a voiceover to land on a specific beat, or a generated animation to be exactly as long as its soundtrack, you're doing math that should be a node. Afloy Audio Duration is that node. It takes one audio wire, gives you the length in seconds and as a frame count at whatever fps you're targeting, and hands you a timecode string for good measure.

It ships in afloy_audio_tools, the same one-package trio as Afloy Audio Info and Afloy Audio Trim. Install once, all three appear under Add Node → audio → Afloy Audio Tools.

How it works

Two inputs: audio (the AUDIO wire from Load Audio) and fps (FLOAT, default 24, range 1–240, stepped by 0.001 so you can type oddball rates like 23.976). The math is unashamedly simple - it counts samples in the waveform tensor, divides by the sample rate, and multiplies by fps:

  • duration_sec (FLOAT) - the real length
  • duration_sec_int (INT) - truncated whole seconds
  • frames (INT) - duration_sec × fps, this is the star of the show
  • timecode (STRING) - MM:SS with hundredths
  • sample_rate (INT) - Hz
  • channels (INT) - mono/stereo as the tensor holds it

The frames output is the one you'll reach for. Set fps to your target output frame rate and wire frames into whatever node wants to know how long the result should be - video-out configurations, frame-count conditioners, that kind of thing. If your audio is 10 seconds and you're rendering at 30 fps, you get 300, exactly, no mental arithmetic.

There's no decoding happening here - no ffmpeg under the hood, no extra pip dependencies. It reads the tensor that ComfyUI already has in memory, which makes it instant and makes the sample_rate and channels outputs trustworthy for debugging, since they reflect what the pipeline actually loaded.

Installing it

It's the same shared install for the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/afloy011-spec/afloy_audio_tools.git "Afloy Audio Tools"

Restart ComfyUI. Or use ComfyUI Manager and search "Afloy Audio Tools". No model files, no requirements.txt - just numpy and torch, both already present. Compared to the usual custom-node install, which can mean wrestling conflicting dependencies for an afternoon, this is about as frictionless as it gets.

Gotchas worth knowing

duration_sec_int uses int(), so it truncates rather than rounds - a 9.9-second clip reports 9. If you need ceiling rounding, grab duration_sec and do it in a math node instead. The timecode format uses hundredths of a second (the pack's _fmt_time multiplies the fractional part by 100), so it's fine for marking a cut, not for frame-accurate work. And remember the frames count is only as honest as your fps - set it to your real output rate, not the one you wish you were using.

Pair it with Afloy Audio Trim and you've got a tidy audio station inside ComfyUI: cut the clip, then confirm the trimmed length and frame count without leaving the graph.

Categoryaudio/Afloy Audio Tools

Inputs (2)

NameTypeDefaultDescription
audioAUDIO
fpsFLOAT24.0001–240

Outputs (6)

NameTypeDescription
duration_secFLOAT
duration_sec_intINT
framesINT
timecodeSTRING
sample_rateINT
channelsINT