🎵 Extract Audio Info
Pull duration, sample rate, and channels out of any audio node's output
- audio
- duration
- sample_rate
- channels
- metadata
ComfyUI's AUDIO type is a dict, not a file - it's a bundle of a waveform buffer, a sample rate, and often a path. When you need to know how long that audio is, or at what rate it's sampled, you're stuck reading a debug printout or eyeballing it. ExtractAudioInfo does the reading for you: feed it any AUDIO output and it returns four facts - duration (seconds, FLOAT), sample_rate (Hz, INT), channels (INT), and metadata (DICT).
The mechanism is more defensive than most utility nodes bother to be, and that's the interesting part. It checks the audio dict for whatever keys the loader happened to use - data / samples / array / waveform, sample_rate / samplerate / sr, path / filepath / filename - because different ComfyUI audio loaders disagree on naming. Then it prioritizes the file path when one exists: it opens the file with soundfile and reads the whole file's length rather than trusting a possibly-truncated in-memory buffer. The author left a comment admitting this ordering fixes a "single-sample bug" where the buffer only carried one frame. If there's no usable path, it falls back to computing from the buffer + rate directly, and raises an error only if neither route works. In practice this means it plays nice with whatever audio source is upstream of it, which is more than you can say for most audio-adjacent nodes.
What the outputs are actually for:
- duration is the one you'll wire most - it feeds straight into
CalculateVideoFrameCount(same pack) to answer "how many frames of video does this audio need?" - sample_rate matters when you're about to resample or feed audio to a model that wants a specific rate.
- channels tells you whether you're holding mono or stereo before you normalize.
- metadata is a small dict describing the source of the info (
sf.infovs in-memory, plus format/subtype) - useful for debugging, rarely useful downstream.
The honest caveats
This node's one real dependency beyond ComfyUI is soundfile (libsndfile). It reads what libsndfile reads: WAV, FLAC, OGG/Vorbis, and MP3 if your libsndfile build supports it - which is most modern installs but not every one. If a file you can play everywhere returns garbage here, that's usually the culprit.
And the usual pack-level gotcha applies: ThimPatUtils ships no requirements.txt despite the README telling you to install one, and its load-time imports mean a missing soundfile or cv2 unregisters all six of its nodes at once. Install from ComfyUI Manager ("Multimedia Utilities") or git clone https://github.com/thimpat/ThimPatUtils into custom_nodes/, then:
python -m pip install soundfile opencv-python
Restart, and the audio tools show up under 🎨 ThimPatUtils/Audio Tools.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| duration | FLOAT | — |
| sample_rate | INT | — |
| channels | INT | — |
| metadata | DICT | — |