Nodes/Comfyui-PainterAudioLength/Painter Audio Length
ComfyUI Node

Painter Audio Length

The node that tells you how long your audio is

By princepainter·Created 9 months ago·Updated 2 months ago· 3
Painter Audio Length
  • audio
  • duration_seconds

ComfyUI does a lot of the arithmetic in your head for you - until it doesn't. You load a ten-second clip and nowhere does it just hand you 10.0 as a number you can wire into a frame counter. That gap is exactly what PainterAudioLength exists to fill. It's a node with one input and one output and maybe twenty lines of actual logic. The name isn't a marketing overpromise: it computes audio duration, full stop.

The context matters more than the node. ComfyUI picked up native audio support alongside the video models: the AUDIO type is a plain dict, {sample_rate: int, waveform: torch.Tensor}, flowing out of nodes like LoadAudio. And once Wan and LTX-2 started shipping synchronized audio-plus-video generation, a big slice of real workflows became about trimming, aligning, and frame-counting audio. This node is the measuring stick for all of it.

What it actually does

Mechanically it's embarrassingly simple, which is the charm. It reads the last dimension of the waveform tensor (the sample count), divides by the sample rate, and rounds to two decimals. Samples ÷ sample rate = seconds. No decoding, no API call, no model file, no key. Feed it nothing and it quietly returns 0.0.

It's one half of a two-node pack: the sibling PainterAudioCut trims audio to exact frame counts at a given frame rate and hands back a total_frame integer (aligned to the 4N+1 shape the video VAEs want). PainterAudioLength is the "so how long did that turn out to be?" node you hang next to it. The whole repo is tiny, with no models and no heavy dependencies - refreshing in an ecosystem where half your installs feel like they come with a second computer.

Where it fits in a real workflow

The boring-but-useful job: you need the duration as an actual number to plug into something else. Wire duration_seconds into a MathExpression to convert seconds to frames at your fps, feed it into a primitive that sizes a video latent, or just sanity-check that your "ten second" clip really came out as 10.0 and not 9.87. If you're syncing generated video to an input audio track - the standard Wan/LTX audio-reactive setup - knowing the exact duration before you commit to end frames saves a whole regeneration cycle of trial and error.

The inputs and outputs that matter

Honestly: one of each.

  • audio (AUDIO) - the only input. Wire it from anything that produces the audio dict: LoadAudio, an upload variant, or the decode node on a Wan/LTX audio VAE. It's marked optional in the schema, but leaving it empty just buys you a 0.0.
  • duration_seconds (FLOAT) - the only output. Feeds math nodes, frame counters, or the sibling PainterAudioCut when you're doing frame math.

Installing it

Via ComfyUI Manager: search "Comfyui-PainterAudioLength" (the pack title) and install. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/princepainter/Comfyui-PainterAudioLength

Then restart ComfyUI. That's the whole install. There's no requirements.txt, no model download, nothing to babysit. The only third-party import is torchaudio, which ComfyUI already ships for its native audio support - so this is one of those rare custom nodes that doesn't drag dependency roulette into your environment.

Gotchas and troubleshooting

There's not much to go wrong, which is the appeal. A few things worth knowing:

  • Feed decoded audio, not audio latents. Both this node and its sibling index audio["waveform"] and audio["sample_rate"] directly. Wan and LTX produce audio latents first; those need a VAE decode before they're a real AUDIO dict. Wire the wrong thing and you'll hit a key error or a silent 0.0.
  • The two-decimal rounding is real. That's up to a few milliseconds of slop at common sample rates. Fine for trimming; if you need exact sample counts, use PainterAudioCut's total_frame output instead.
  • Empty input returns 0.0 silently. If your workflow suddenly reports zero-length audio, check that the AUDIO wire is actually connected and populated.

It's not a node you'll gush about. But the next time you need a duration as a number instead of eyeballing a waveform, it's the one you'll reach for - and it does the one job without breaking your environment to do it.

Categoryaudio

Inputs (1)

NameTypeDefaultDescription
audiooptAUDIO

Outputs (1)

NameTypeDescription
duration_secondsFLOAT