ComfyUI Node

Save Audio

The 1hewNodes Save Audio node does FLAC, WAV, MP3 and Opus

By 1hew·Created 2 years ago·Updated 2 days ago· 35
Save Audio
  • audio
  • file_path
◄filenameaudio/ComfyUI►
◄formatmp3►
◄auto_incrementtrue►
◄save_outputtrue►
◄save_metadatatrue►

The problem it actually solves

Audio is the layer ComfyUI bolted on after the fact. The models are fine - ACE-Step for instrumentals, Chatterbox for voices - but the plumbing is whatever each wrapper happened to ship, so you generate a take you like and find the only available format is the one that pack's saver offers. "How do I get this out as FLAC, I can only pick MP3" is a recurring snag.

Save Audio from ComfyUI-1hewNodes fixes that. It takes an AUDIO object and writes it as flac, wav, mp3 or opus, your choice, with control over the name, the folder, and whether it lands in output/ or temp/. It hands back the absolute path as a string, which makes it useful mid-pipeline, not just at the end of one.

How it works under the hood

No soundfile here, unlike ComfyUI's built-in savers. It encodes through PyAV, one container/codec pair per format: flac→flac, wav→pcm_s16le, mp3→libmp3lame, opus→libopus. The waveform is normalised to a [batch, channels, samples] tensor, each batch item becomes its own file, and frames reach the encoder as 32-bit float. Two things worth knowing:

  • WAV here is 16-bit. pcm_s16le is right there in the code, so wav is the lossy-in-practice choice in this menu. Archiving? Use flac.
  • MP3 is a fixed 320 kbps, Opus a fixed 192 kbps. No bitrate knob - fine for delivery, not something you tune.

Lossy encoders only take certain sample rates, and the node snaps to the nearest supported one rather than failing. MP3 lists 44100, so a 44.1 kHz file passes through untouched; Opus has no 44.1 entry, so 44.1 kHz gets resampled to 48 kHz. FLAC and WAV keep the source rate.

The inputs that matter

Only audio is optional; the rest are widgets. The four you'll touch:

  • format - flac (default), wav, mp3, opus. It sets the extension, so don't type one into the filename; anything after the last dot in your prefix is stripped.
  • filename - path prefix, default audio/ComfyUI, relative to ComfyUI's output directory. Date placeholders like %date:yyyy-MM-dd% work; an absolute path writes there instead of into output/.
  • auto_increment - true gives ComfyUI_00001_.flac, _00002_, and so on. false writes ComfyUI.flac and overwrites every run - handy if something downstream watches a stable path, painful the one time it eats a take.
  • save_output - off means temp/ instead of output/. Good for audition runs: player, no litter.

save_metadata stuffs the prompt and workflow JSON into the container metadata - handy six weeks later when you want to know which seed made a track. Skipped under --disable-metadata.

Because audio is optional and pass-through, an empty or unconnected input writes nothing and returns an empty string. In a video workflow where the clip may or may not have a soundtrack, that's a graceful no-op instead of a crash - but a downstream text node gets "".

The output

file_path is a STRING: the absolute path of what was written, newline-joined for a batch, so it drops straight into Save Text if you want a manifest. The node also pushes the file to the frontend, which gives you the embedded player. One catch: write to an absolute path outside ComfyUI's served directories and the player can't fetch it - it plays the input audio instead.

Installing it

ComfyUI Manager, search the pack title ComfyUI-1hewNodes, or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart ComfyUI properly, then Add Node → 1hewNodes → io → Save Audio. Its display name is identical to ComfyUI's own Save Audio, so search shows two with the same label - the category line tells them apart.

The pack's requirements.txt is heavy - opencv, scikit-image, ultralytics, rembg, transparent-background, onnxruntime, psd-tools, torchaudio. Most of it serves the background-removal and PSD nodes, and those imports are lazy, so a half-installed env won't take your node menu down - but the pip step can still start a wrestling match with torchaudio. For this node, PyAV is the whole requirement, and ComfyUI already ships av.

Where people get burned

A missing codec. libopus isn't in every PyAV build. Pick opus and get Save Audio failed to encode …, that's the codec, not your audio - use flac or wav. It at least deletes the half-written file instead of leaving a 0-byte artefact.

More than two channels. Mono and stereo only, and it errors clearly rather than writing a broken file. Fold surround-ish intermediates down first.

A batch with a fixed name. auto_increment=false on a 4-item batch writes name.flac then name_001..003, and the next run rewrites all four.

Category1hewNodes/io

Inputs (6)

NameTypeDefaultDescription
filenameSTRINGaudio/ComfyUI保存文件名或路径前缀;支持格式占位符(如 %date:yyyy-MM-dd%)。
formatCOMBOmp3保存格式;默认 mp3(320 kbps,有损,体积小、兼容性好),需要无损归档时选 flac / wav;mp3 / opus 在采样率不受支持时会重采样。
auto_incrementBOOLEANtrue为 True 时自动编号;为 False 时固定文件名并覆盖。
save_outputBOOLEANtrue是否保存到输出目录;若为 False 则保存到临时目录。
save_metadataBOOLEANtrue是否写入 prompt/workflow 元数据。
audiooptAUDIO要保存的音频;为空时节点直接通过,不写任何文件。

Outputs (1)

NameTypeDescription
file_pathSTRING—