MediaUtilities_AudioDuration
One input, one float — the node that tells you how long your audio actually is
- audio
- duration
It's the smallest node in ComfyUI-MediaUtilities, and probably the one you'll reach for more than you expect. Feed it any AUDIO and it hands back a duration in seconds - one number, nothing else. That sounds boring until you're building an audio-aware workflow and realize "how long is this clip?" is the number everything downstream depends on.
Why you'd reach for it
ComfyUI keeps getting more audio-aware. LTX-2.3 ships native synchronized audio and video, and the community's standing workaround for silent models like Bernini is literally "run it through LTX and grab the audio that way." Once audio is a first-class object in your graph, you want its length as a plain number you can feed into other nodes - set a frame count, size a latent, decide whether to extend the clip, or just eyeball the result in the UI. Other packs have duration nodes, but if you're already running this one for the URL loader, this is the no-extra-install answer.
How it works
ComfyUI passes audio around as a dict: a waveform tensor shaped [batch, channels, samples] plus an integer sample_rate. The node takes the first waveform in that batch, counts the samples along the time axis, and divides by the sample rate. Samples ÷ rate = seconds. That's the entire mechanism - the same math torchaudio does internally, exposed as a node so the number stays live in your graph instead of living in your head.
On any error it returns 0.0 rather than raising, which is worth remembering when you debug.
Inputs and outputs
- audio (AUDIO) - the only input. Wire it from
MediaUtilities_AudioURLLoaderor any other node that produces the standard ComfyUI audio type. - duration (FLOAT) - the clip length in seconds, a plain number you can plug into math, text, or conditioning nodes.
Installing it
It ships in ComfyUI-MediaUtilities, so install the pack once and all three of its audio/video nodes come along. Easiest route is ComfyUI Manager: Manager → Install Custom Nodes → search "ComfyUI-MediaUtilities". Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ThanaritKanjanametawatAU/ComfyUI-MediaUtilities
cd ComfyUI-MediaUtilities
pip install -r requirements.txt
Then restart ComfyUI. No model files to download - the whole pack is pure Python, and torch/torchaudio are usually already in your ComfyUI environment. If you're on the Windows portable build, run that pip from the embedded Python so it lands in the right environment.
Gotchas
Two small ones, both from reading the source:
- It reads only the first waveform in a batch. A batch of several clips gives you the first one's length.
- Failure is silent: you get
0.0, not an error. If a duration suddenly reads zero, your audio is almost certainly empty - which is this pack's other habit (the URL loader returns a second of silence instead of throwing). Treat a0.0as a smoke alarm, not a red herring.
That's the whole node. It doesn't pretend to be more than it is, and for the one number it's the fastest way to get it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| duration | FLOAT | — |