The Computer Oracle

How do I replace the audio in an MP4 file without re-encoding?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3

--

Chapters
00:00 How Do I Replace The Audio In An Mp4 File Without Re-Encoding?
00:42 Accepted Answer Score 48
01:03 Answer 2 Score 14
01:23 Answer 3 Score 3
01:39 Answer 4 Score 0
01:54 Thank you

--

Full question
https://superuser.com/questions/602662/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #audio #mp4 #videoencoding

#avk47



ACCEPTED ANSWER

Score 48


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




ANSWER 2

Score 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.




ANSWER 3

Score 3


There are several free software for this:

and many others at videohelp.com




ANSWER 4

Score 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.