Nodes/ComfyUI-Get-Random-File/Preview Audio w/ Length ⚑
ComfyUI Node

Preview Audio w/ Length ⚑

The runtime number ComfyUI never handed you

By ChrisColeTechΒ·Created 2 years agoΒ·Updated a day agoΒ· 3
Preview Audio w/ Length ⚑
  • audio
  • audio
  • length

ComfyUI's stock Preview Audio node plays your clip and gives you nothing back. That's usually fine - until you're building a talking-head or lip-sync pipeline and you need to know exactly how many seconds of audio you have, before you commit GPU time to a video that has to cover it. Preview Audio w/ Length ⚑ is one input, two outputs, and it hands you that number as a float.

What it actually does

One job, done properly: it takes an AUDIO and tells you how long it is.

Mechanically, ComfyUI's AUDIO is a dict with a waveform tensor and a sample_rate. The node does waveform.shape[-1] / sample_rate - samples divided by sample rate - which is your duration in seconds. Then it passes the audio straight back out untouched, alongside that float.

It's also an output node (OUTPUT_NODE = True), and it returns its preview payload through ComfyUI's own UI.PreviewAudio API object rather than faking anything. In practice that means you get the native playback widget - the same transport controls, scrubbing and download button you'd get from core Preview Audio. Pack authors usually get this wrong and end up with a dead little audio box; this one doesn't.

Inputs and outputs

There's exactly one input: audio (AUDIO, required).

Two outputs:

  • audio - the same audio, passed through. Wire it onward to your save node, or to a lip-sync node like InfiniteTalk/MultiTalk, or into LTX-2's native audio+video, so picture and sound come from one pass.
  • length - a FLOAT, seconds.

The pass-through is the quietly useful part: drop it inline in an existing chain and nothing breaks - same audio out, plus a number you didn't have.

Why you'd want the number

Two reasons, both practical.

First, audio-driven video has a hard duration rule. Lip-sync and avatar models are driven by the audio track; if the video is shorter than the audio, the clip hangs on its final frame while the voice keeps going. Knowing the length up front lets you size the video - length Γ— fps, via a math or primitive node - instead of discovering the problem after the render.

Second, video generation is where your compute actually goes. One 2025 InfiniteTalk workflow reported roughly 33 seconds of generation per second of lip-synced video on a 3090. Measuring a stray 12-second narration before you render it is cheap insurance.

Wire length into a float primitive if you want an authoritative value on the graph, or straight into whatever node has a "length in seconds" input. If you're converting to frames, see Text β†’ Frames (Speech Estimate) in the same pack, or just multiply by your model's fps.

Install

No models, no heavy dependencies, nothing to configure.

ComfyUI Manager: open the Manager, search ComfyUI-Get-Random-File, install it, restart ComfyUI.

Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/ChrisColeTech/ComfyUI-Get-Random-File

Then restart the server and hard-refresh the browser tab. The pack's requirements.txt only lists imageio-ffmpeg and requests - but this node's file imports more than that; see below.

Fair warning: the pack README doesn't mention this node at all. It documents the random-file and save nodes. These audio nodes ship anyway. Search the node browser for the class name or look under the πŸ€– CCTech/Files category.

Common issues

The whole pack fails to load, not just this node. audio_w_length.py imports av (PyAV) and from comfy_api.latest import UI at module level, and __init__.py imports that module unconditionally. On an older ComfyUI build where comfy_api.latest doesn't exist, the import blows up and you lose every node in the pack - including the random-file ones you came for. The console traceback names the failing import; the fix is updating ComfyUI, not reinstalling the pack.

av isn't in requirements.txt. It's needed here, but it isn't installed by the pack - it comes with ComfyUI itself on any recent version. If you're on a trimmed-down or containerised install missing PyAV, this node won't register. python -c "import av" in your ComfyUI env settles it.

"Audio input is None" / "must contain 'waveform' and 'sample_rate'." The node validates hard and says so. You've fed it something that isn't a real AUDIO - usually an unconnected optional input, or a text/string where audio should be.

The length looks wrong for a batch. It's computed from the last dimension of the waveform tensor, so a batched AUDIO reports one duration - samples Γ· sample rate - not a per-item list. If your batch items differ in length, that number describes the tensor, not each clip. And the pack prints a single [CCTech Suite]: ... Activated N file nodes. line on startup, so check the console if you're not sure it loaded at all.

CategoryπŸ€– CCTech/Files

Inputs (1)

NameTypeDefaultDescription
audioAUDIOβ€”

Outputs (2)

NameTypeDescription
audioAUDIOβ€”
lengthFLOATβ€”