🎬🔊AGSoft Replace Audio To Video
Swap a video's audio without re-encoding the video
- video
- audio
- video_path
- duration_seconds
- duration_timecode
- file_size_mb
- width
- height
- fps
- frames_est
🎬🔊AGSoft Replace Audio To Video is the dubbing node. It takes a video and a new audio track and puts them together - and critically, it does it without re-encoding the video. FFmpeg stream-copies the video packets, so a big generated clip gets new sound in seconds instead of a full re-render. If you've ever re-encoded a 4K clip just to change the voiceover and watched the quality (and the encode time) crawl, you get why this matters.
This is the natural partner to the pack's audio tools: extract the original audio with Extract Audio From Video, generate or load a replacement, and swap it in here.
How it works
The video source is the optional video input (priority) or video_path. The voiceover is audio_path (a file, priority) or the audio AUDIO input. Then audio_mode decides how the two lengths reconcile - and this is the field that actually shapes your result:
fit- trim the track or pad it with silence so it matches the video's length. The safe default for a voiceover that's roughly the right length.loop- repeat the track across the whole video. Perfect for a music bed.trim_to_audio- the opposite direction: cut the video down to the audio's length. Great when the sound is the boss (a song, a finished VO) and the picture just has to fit it.
You also get audio_volume (0–2 multiplier, 1.0 = original), audio_fade_in and audio_fade_out (0–60s) for the new track. output_name is the filename (keep the .mp4 extension as default), output_path the folder, empty = ComfyUI/output.
Outputs
video_path(STRING) - the muxed result.duration_seconds,duration_timecode,file_size_mb.width,height,fps,frames_est- the original video's specs, passed through unchanged (which is the whole point of stream copy).
Install
Part of the comfyui-AGSoft pack. ComfyUI Manager → search "comfyui-AGSoft" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft
Restart. No model downloads; the node drives the FFmpeg binary ComfyUI bundles (or a system ffmpeg on PATH).
Where people get burned: the "no re-encode" guarantee is about the video. The audio almost always gets re-encoded into the container (or at least remuxed), so don't expect bit-perfect sound - expect fast, clean muxing. And if you're replacing audio on a clip whose track is longer than the video, fit will cut it off; reach for loop or trim_to_audio depending on which side should win.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| output_name | STRING | replaced_audio.mp4 | Output filename. The extension is kept as entered (.mp4 by default). --- Имя итогового файла. Расширение сохраняется как введено (по умолчанию .mp4). |
| output_path | STRING | Output directory. If empty, ComfyUI/output is used. --- Папка сохранения. Если пусто, используется ComfyUI/output. | |
| video_path | STRING | Path to the source video. Used only if video input is not connected. --- Путь к исходному видео. Используется, только если вход video не подключен. | |
| audio_path | STRING | Path to the new audio file. Takes priority over the audio input. --- Путь к новому аудиофайлу. Имеет приоритет над входом audio. | |
| audio_mode | COMBO | fit | fit = trim/pad silence to video length. loop = loop track to video length. trim_to_audio = cut the VIDEO to the audio length. --- fit = обрезать/добить тишиной под длину видео. loop = зациклить под длину видео. trim_to_audio = обрезать ВИДЕО под длину аудио. |
| audio_volume | FLOAT | 1.000–2 | New track volume multiplier. 1.0 = original. / Множитель громкости. 1.0 = оригинал. |
| audio_fade_in | FLOAT | 0.00–60 | New track fade-in in seconds. / Появление дорожки в секундах. |
| audio_fade_out | FLOAT | 0.00–60 | New track fade-out in seconds. / Затухание дорожки в секундах. |
| videoopt | VIDEO | Optional base video from ComfyUI. Has priority over video_path. --- Опциональное базовое видео из ComfyUI. Имеет приоритет над video_path. | |
| audioopt | AUDIO | Optional voiceover from ComfyUI. Used only if audio_path is empty/invalid. --- Опциональная озвучка из ComfyUI. Используется, только если audio_path пуст/неверен. |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| video_path | STRING | — |
| duration_seconds | FLOAT | — |
| duration_timecode | STRING | — |
| file_size_mb | FLOAT | — |
| width | INT | — |
| height | INT | — |
| fps | FLOAT | — |
| frames_est | INT | — |