Nodes/comfyui-AGSoft/🎬🔊AGSoft Replace Audio To Video
ComfyUI Node

🎬🔊AGSoft Replace Audio To Video

Swap a video's audio without re-encoding the video

By Art-xmaster·Created about a year ago·Updated a day ago· 24
🎬🔊AGSoft Replace Audio To Video
  • video
  • audio
  • video_path
  • duration_seconds
  • duration_timecode
  • file_size_mb
  • width
  • height
  • fps
  • frames_est
output_namereplaced_audio.mp4
output_path
video_path
audio_path
audio_modefit
audio_volume1.00
audio_fade_in0.0
audio_fade_out0.0

🎬🔊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.

CategoryAGSoft/Video

Inputs (10)

NameTypeDefaultDescription
output_nameSTRINGreplaced_audio.mp4Output filename. The extension is kept as entered (.mp4 by default). --- Имя итогового файла. Расширение сохраняется как введено (по умолчанию .mp4).
output_pathSTRINGOutput directory. If empty, ComfyUI/output is used. --- Папка сохранения. Если пусто, используется ComfyUI/output.
video_pathSTRINGPath to the source video. Used only if video input is not connected. --- Путь к исходному видео. Используется, только если вход video не подключен.
audio_pathSTRINGPath to the new audio file. Takes priority over the audio input. --- Путь к новому аудиофайлу. Имеет приоритет над входом audio.
audio_modeCOMBOfitfit = 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_volumeFLOAT1.000–2New track volume multiplier. 1.0 = original. / Множитель громкости. 1.0 = оригинал.
audio_fade_inFLOAT0.00–60New track fade-in in seconds. / Появление дорожки в секундах.
audio_fade_outFLOAT0.00–60New track fade-out in seconds. / Затухание дорожки в секундах.
videooptVIDEOOptional base video from ComfyUI. Has priority over video_path. --- Опциональное базовое видео из ComfyUI. Имеет приоритет над video_path.
audiooptAUDIOOptional voiceover from ComfyUI. Used only if audio_path is empty/invalid. --- Опциональная озвучка из ComfyUI. Используется, только если audio_path пуст/неверен.

Outputs (8)

NameTypeDescription
video_pathSTRING
duration_secondsFLOAT
duration_timecodeSTRING
file_size_mbFLOAT
widthINT
heightINT
fpsFLOAT
frames_estINT