Merge Video + Audio (ffmpeg)
Swap a video's soundtrack the easy way
- output_path
Sometimes you render a silent video and you just want the music on it. No mixing, no ducking, no "keep the original audio" - the video has no audio worth keeping, and you want to mux an audio file onto it. That's this node: video file in, audio file in, one MP4 out. It's the simplest member of the Simple Video Effects pack, and it's the "replace the track" counterpart to the pack's Add Soundtrack node (which mixes music under existing audio). This one swaps.
There's nothing clever or opinionated here, and that's the point. If you've ever typed out an ffmpeg command for exactly this and then lost it in your shell history, this node is that command with a UI.
How it works
The node runs ffmpeg to combine the video stream from video_path with the audio from audio_path, encoding the audio as AAC for broad compatibility. The trim_to_audio toggle (default true) decides the output length: on, the video is trimmed to match the audio; off, it follows the video and the audio gets cut/looped as needed. The output is written with your output_filename and returned as a path.
Inputs and output
video_path- the video file.audio_path- the audio file to use as the soundtrack.output_filename- name for the result, defaultoutput.mp4.trim_to_audio- trim the video to the audio's length (default true).
Output is output_path - the full path to the merged file.
The two decisions that matter are trim_to_audio and the audio source itself. With trim on (the default), a 30-second song on a 2-minute video gives you a 30-second video - which surprises people once. If you want the whole video with the music, turn trim off.
Installing it
Ships with the Simple Video Effects pack:
cd ComfyUI/custom_nodes
git clone https://github.com/scofano/ComfyUI-Simple-video-effects
cd ComfyUI-Simple-video-effects
pip install -r requirements.txt
Restart ComfyUI, or install via ComfyUI Manager (search "Simple Video Effects"). No models. ffmpeg and ffprobe must be on your system PATH - the node shells out to the binary and fails with a "not found on PATH" error otherwise.
Common issues
The trim behavior is the one that bites: leaving trim_to_audio on with a long track or a short video produces an output that ends when the music ends, and a mismatch can look like data loss if you weren't expecting it. Also, this node replaces audio - if you run it on a video that already has a track you wanted to keep, that track is gone. And because ffmpeg's error output is surfaced when things go wrong, a "Failed to run ffmpeg" error almost always means a path problem: check both input paths exist and that the audio file is a format ffmpeg can decode.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | — | |
| audio_path | STRING | — | |
| output_filename | STRING | output.mp4 | — |
| trim_to_audio | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_path | STRING | — |