Nodes/ComfyUI_UniversalMediaLoader/Universal Audio Unpack
ComfyUI Node

Universal Audio Unpack

Trimmed, time-stretched, and ready to wire

By Fictiverse·Created about 23 hours ago·Updated about 23 hours ago· 7
Universal Audio Unpack
  • media_data
  • audio
  • sample_rate
  • duration
  • orig_duration
  • trim_start
  • trim_end
  • channels
  • filename

Audio is the forgotten half of most ComfyUI media workflows - everyone loads images and video, nobody thinks about the soundtrack until they need it. UniversalAudioUnpack fixes that. Wire it to a UniversalMediaLoader that has an audio file or a video file dropped on it, and it hands you the trimmed, optionally time-stretched audio as a proper ComfyUI AUDIO dict, ready for PreviewAudio, SaveAudio, or anything that consumes audio conditioning.

How it works

The node reads the MEDIA_DATA JSON the loader produces, finds the file, and decodes it with a graceful fallback chain: torchaudio first, then soundfile, then PyAV - whichever your install happens to have. Then it does three things:

  1. Trims to the trim_start / trim_end seconds you set on the loader's waveform timeline, sample-accurately.
  2. Time-stretches if you turned on playback speed in the loader. Speed runs from 0.10x to 4.00x, and it's a real time-stretch with pitch preserved - implemented via FFmpeg's atempo filter, which is why the pack's only outside-binary dependency appears here.
  3. Packages the result into the {"waveform", "sample_rate"} dictionary ComfyUI's AUDIO type expects.

Because it accepts MEDIA_DATA from video too, you can pull the soundtrack out of an MP4 and use it separately while UniversalVideoUnpack handles the frames. The two nodes read the same trim values, so the audio you get lines up with the frames you get.

The outputs

  • audio - the AUDIO dict. This is the one you wire into preview/save or conditioning.
  • sample_rate - e.g. 44100. Useful if you're building audio processing chains that need to know.
  • duration - the trimmed/time-stretched length in seconds. orig_duration is the source file's full length.
  • trim_start / trim_end - the boundaries actually used, in seconds.
  • channels - how many channels survived decode.
  • filename - the source file name.

Installing

Same pack, same drill: ComfyUI Manager (search "Universal Media Loader") or:

cd ComfyUI/custom_nodes/
git clone https://github.com/Fictiverse/ComfyUI_UniversalMediaLoader.git

Restart ComfyUI. No extra Python deps and no models.

Gotchas worth knowing

  • The speed feature needs FFmpeg. The pack grabs the copy imageio-ffmpeg bundles with ComfyUI, or a system ffmpeg if you have one. If neither exists, time-stretch silently gives up and returns the audio unchanged with a console warning - your duration will then disagree with the speed you set. If you care about speed, make sure ffmpeg is findable.
  • Feed it image or canvas media_data and you get a silent zero-length placeholder, not an error. Not a bug - the pack's way of keeping every unpack robust to whatever the loader was holding. If your audio output looks "empty," check what's actually dropped on the loader.
  • Trimming is applied sample-accurately server-side, but the loader's 1-second magnet snap on the timeline is a UI nicety - toggle it off if you need finer boundaries.
Categoryloaders/universal_media

Inputs (1)

NameTypeDefaultDescription
media_dataoptMEDIA_DATA

Outputs (8)

NameTypeDescription
audioAUDIO
sample_rateINT
durationFLOAT
orig_durationFLOAT
trim_startFLOAT
trim_endFLOAT
channelsINT
filenameSTRING