Nodes/comfyui-lopi999-nodes/Load Audio Base64
ComfyUI Node

Load Audio Base64

Turn a base64 blob back into playable audio

By LaVie024·Created about a year ago·Updated 8 months ago· 8
Load Audio Base64
    • AUDIO
    base64_audio
    hint_extension.wav
    strict_base64true
    parse_data_uritrue
    auto_detect_extensiontrue

    Base64-encoded audio shows up in a surprising number of places: API responses, embedded data URIs, and the "here's a sound, but only as text" corner of every integration you've ever fought. LoadAudioBase64 takes that blob, decodes it, and hands ComfyUI a proper AUDIO output - with extension auto-detection and data-URI parsing so you don't have to be pedantic about the input format. It's the least flashy node in this pack and the one with the most moving parts under the hood.

    Why you'd reach for it

    ComfyUI's audio ecosystem (audio-to-video, lip-sync, music generation) needs an AUDIO-typed tensor, and you usually load that from a file. But some workflows receive audio as base64 - from a web service, an API, or a saved state - and no stock node decodes it. This is that missing piece. If you're building automation around audio generation, you'll hit this need sooner than you think.

    How it works

    The pipeline is genuinely thoughtful. First it optionally parses a data:<mime>;base64,... data URI to pull out the MIME type. Then it base64-decodes the payload (strict or lenient per strict_base64), then - if auto_detect_extension is on - sniffs the actual file magic bytes: RIFF....WAVE means wav, fLaC means flac, OggS means ogg, ID3 or a frame-sync byte means mp3, FORM means aiff. That sniffing matters because a wav without its .wav suffix is undecodable by format-agnostic tools.

    The decoded bytes go to a temp file with the right extension and get loaded through a decoder chain: PyAV (av) first if installed, then ffmpeg/ffprobe if on PATH, then the Python stdlib wave reader as a last resort for wav. The output is the standard ComfyUI AUDIO dict - a [B, C, T] waveform plus sample rate. All the format guessing means the hint_extension input is mostly a fallback for the rare case where sniffing fails.

    The inputs that matter

    • base64_audio (STRING) - the blob. Paste it or wire it.
    • hint_extension (enum: .wav, .mp3, .ogg, .flac, .aiff, .aif) - fallback extension when detection fails.
    • strict_base64 (BOOLEAN, default true) - strict base64 validation vs lenient decoding.
    • parse_data_uri (BOOLEAN, default true) - strip and use a data: URI's MIME type.
    • auto_detect_extension (BOOLEAN, default true) - magic-byte sniffing. Keep this on.
    • AUDIO - the decoded audio, wired into whatever expects it.

    Installing it

    The pack has no requirements.txt, and this is the node where that bites hardest. The happy path needs either PyAV or ffmpeg on your system:

    cd ComfyUI/custom_nodes
    git clone https://github.com/LaVie024/comfyui-lopi999-nodes
    pip install av        # PyAV - recommended, it's used first
    # or make sure ffmpeg/ffprobe are on PATH
    

    Then restart ComfyUI, or find "comfyui-lopi999-nodes" in ComfyUI Manager.

    Common issues

    The error you'll actually see is Unable to decode audio. Install PyAV ... or ensure ffmpeg/ffprobe are on PATH - that's the node working as designed when no decoder is available. Install av and it goes away. Also, base64 padding is handled (the node adds = padding as needed), but whitespace and line breaks in the blob can trip strict mode; if a paste fails, try strict_base64 off. And this is the pack's one node where "no extra dependencies" is emphatically not true - budget for a decoder install.

    Categoryaudio

    Inputs (5)

    NameTypeDefaultDescription
    base64_audioSTRING
    hint_extensionCOMBO.wav6 options: .wav, .mp3, .ogg, .flac, .aiff, .aif
    strict_base64BOOLEANtrue
    parse_data_uriBOOLEANtrue
    auto_detect_extensionBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    AUDIOAUDIO