31

I've got a video in an MP4 container that I would like to replace the audio track in (not add another audio stream to, nor convert the audio format of).

Someone elsewhere online suggested to use VirtualDub to replace the audio track, but it wouldn't even open up the video file. Journeyman Geek suggested in chat that I use ffmpeg, but the documentation is pretty difficult for me to understand.

How can I accomplish this on Windows? I'll download/install external programs if I must.

nc4pk
  • 9,037
  • 14
  • 59
  • 71

4 Answers4

46

I ended up scrutinizing the documentation for ffmpeg and worked out a solution:

ffmpeg.exe -i input_video.mp4 -i replacement_audio.m4a -vcodec copy -acodec copy -map 0:0 -map 1:0 output.mp4

nc4pk
  • 9,037
  • 14
  • 59
  • 71
14

An addition to the current solution: If the audio file does not match the video container's format, just avoid the -acodec parameter:

ffmpeg.exe -i input_video.mp4 -i replacement_audio.m4a -vcodec copy -map 0:0 -map 1:0 output.mp4

Now, only the audio gets encoded in order to match the container.

3

There are several free software for this:

and many others at videohelp.com

T.Todua
  • 3,815
  • 9
  • 42
  • 57
  • 1
    MP4Box seems very simple and I didn't find any option to replace audio, but MKVToolNix GUI is easy to understand and does a great job! – Vitas Aug 26 '19 at 19:17
  • 1
    I confirm that MKVToolNix works to merge video and audio without re-encoding, and also it allows to set a delay for the audio. It's available on Linux, MacOSX and Windows. – gaborous Apr 09 '22 at 13:03
0

I'm surprised that no one mentioned onlineconverter.com. In addition to many other goodies, their site allows to add or replace audio in a video file.

Trying it out, replacing the audio in a sample video file does not seem to affect the video.

Shlomi A
  • 101
  • 1
  • 4