Video Audio Merger
The boring node that makes your renders watchable
- video
- audio
- merged_video
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 - LoadVideo → HunyuanVideoFoleyGenerateAudio → VideoAudioMerger → SaveVideo. 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
waveformandsample_rate) that the foley node produces. - audio_sync_mode - the one to think about.
stretchis the sensible default for foley, since generated audio usually isn't exactly as long as the clip.loopis handy for ambience,truncateif you don't care about the tail,pad_silenceif you want the full clip with a quiet ending. - video_codec -
libx264default.copyskips re-encoding entirely (fast, but picky about what the existing stream will accept). - audio_codec -
aacdefault,mp3, orcopy. Stick with aac for an mp4. - quality -
high/medium/lowmaps to bitrate and CRF settings. Only applies when you're actually re-encoding, not withcopy.
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
copycodecs are picky. If you ask forvideo_codec: copyon 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.
atempopreserves pitch but a 10-second clip stretched to fill a 2-minute video sounds wrong. For big mismatches,looporpad_silenceis usually the better call. - Quality presets only matter when re-encoding.
copyignores them entirely, so don't expect thehighbutton 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| video | VIDEO | 输入视频(VIDEO 类型) | |
| audio | AUDIO | 输入音频(AUDIO 类型) | |
| audio_sync_mode | COMBO | stretch | 音频同步模式:stretch=拉伸匹配视频长度,loop=循环播放,truncate=截断,pad_silence=静音填充 |
| video_codec | COMBO | libx264 | 视频编码器 |
| audio_codec | COMBO | aac | 音频编码器 |
| quality | COMBO | medium | 输出质量 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| merged_video | VIDEO | — |