ComfyUI Node

Video Audio Merger

The boring node that makes your renders watchable

By Jarcis-cy·Created about a year ago·Updated about a year ago· 6
Video Audio Merger
  • video
  • audio
  • merged_video
audio_sync_modestretch
video_codeclibx264
audio_codecaac
qualitymedium

The generate node makes the sound; this one makes the file. VideoAudioMerger is the utility half of the HunyuanVideo-Foley pack, and it does exactly one job well: it takes a VIDEO and an AUDIO, gets their durations in sync, and encodes them into a single mp4 with a real audio track. It's the step you'd otherwise be doing in a video editor or by hand in ffmpeg, and it's what turns a generated soundtrack into something you can actually ship.

It belongs at the end of the pack's natural workflow - LoadVideoHunyuanVideoFoleyGenerateAudioVideoAudioMergerSaveVideo. The output of the foley node plugs straight into the audio socket.

How it works

Pure ffmpeg under the hood. Both inputs get written to temp files, the node probes the video's duration, computes the audio's length from sample count ÷ sample rate, then decides what to do with the mismatch based on audio_sync_mode. Stretch (the default) retunes tempo with ffmpeg's atempo filter so the audio lands exactly on the video's length; loop repeats the audio until it covers the clip; truncate just cuts the audio off at the video's end; pad_silence tacks silence onto the tail of audio that runs short. Then both streams get handed to ffmpeg's encoder and a fresh mp4 comes out the other side.

The inputs that matter

  • video and audio - a VIDEO object and the AUDIO dict (with waveform and sample_rate) that the foley node produces.
  • audio_sync_mode - the one to think about. stretch is the sensible default for foley, since generated audio usually isn't exactly as long as the clip. loop is handy for ambience, truncate if you don't care about the tail, pad_silence if you want the full clip with a quiet ending.
  • video_codec - libx264 default. copy skips re-encoding entirely (fast, but picky about what the existing stream will accept).
  • audio_codec - aac default, mp3, or copy. Stick with aac for an mp4.
  • quality - high/medium/low maps to bitrate and CRF settings. Only applies when you're actually re-encoding, not with copy.

Output: merged_video - a VIDEO object. Feed it into SaveVideo or preview it directly.

Installing it

Same pack as the foley node: ComfyUI Manager (search "HunyuanVideo-Foley Audio Generator") or

cd ComfyUI/custom_nodes
git clone https://github.com/Jarcis-cy/ComfyUI-HunyuanVideoFoley
# restart ComfyUI

Then pip install ffmpeg-python into ComfyUI's Python env - that's the only pip dependency this node needs.

Here's where people get burned: ffmpeg-python is a Python wrapper, but it shells out to the actual ffmpeg binary, and the README never mentions that. If you get cryptic "cannot find ffmpeg" or encoding errors, it's almost always the binary missing from PATH, not the pip package. On Windows, grab ffmpeg via winget or choco and make sure it's on PATH; on Linux/Mac, your package manager has it.

Where people get burned

  • copy codecs are picky. If you ask for video_codec: copy on a stream that doesn't match what the container wants, the merge fails. When in doubt, let it re-encode with the default libx264 + aac.
  • Stretch distorts when lengths are wildly different. atempo preserves pitch but a 10-second clip stretched to fill a 2-minute video sounds wrong. For big mismatches, loop or pad_silence is usually the better call.
  • Quality presets only matter when re-encoding. copy ignores them entirely, so don't expect the high button to save a lossy source.

Boring, dependable, and exactly what you need once you've got a soundtrack. That's a good combination in a node.

CategoryHunyuanVideoFoley/Audio

Inputs (6)

NameTypeDefaultDescription
videoVIDEO输入视频(VIDEO 类型)
audioAUDIO输入音频(AUDIO 类型)
audio_sync_modeCOMBOstretch音频同步模式:stretch=拉伸匹配视频长度,loop=循环播放,truncate=截断,pad_silence=静音填充
video_codecCOMBOlibx264视频编码器
audio_codecCOMBOaac音频编码器
qualityCOMBOmedium输出质量

Outputs (1)

NameTypeDescription
merged_videoVIDEO