How do I replace the audio in an MP4 file without re-encoding?
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
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.
There are several free software for this:
- MP4Box GUI
- MKVTOOLKIT
- AviDemux
and many others at videohelp.com