How to add an additional Sound track to an existing Video

I have a MP4 and MKV video file which also has its own Audio track. I want to add an additional track to it to cover another language for it, what Terminal or GUI way is there available to insert and sync a MP3 file to the already existing video so that:

  • The video shows 2 audio tracks (The existing one and the new one am inserting)
  • Optionally the video shows the name of the tracks
  • I can sync the new audio with the video
  • I do not replace the existing audio with the new one
  • Maintain the same video quality as before
    (It is a 1080p video with very high details. Do not want to mess with this since it takes way too long to get it right)

This would help in, for example, adding additional language sound tracks to an existing video.


For now this is what I have found (Still looking for the MKV way of doing it):

MP4 ONLY

You would need to first install gpac package:

sudo apt-get install gpac

Now proceed with the following command:

MP4Box -new -add OriginalMovie.mp4 -add Track2.mp3#audio:delay=300 Output.mp4

Where

  • MP4Box is the command to do this and yes it is capitalized
  • The first -new will tell MP4Box a new file will be created. You could put this at the end like "-new Output.mp4" but I wanted to put it in the beginning.
  • The first -add is to add the Original video file.
  • The second -add is to add the new track which I called Track2.mp3. It can have any other name.
  • The part that has the #audio:delay=300 is to tell MP4Box that this specific new track I am adding is an audio track and I need to add a Delay of 300 ms.

This way I can add the original video, insert a new track and even control the sync. The best part is, since MP4Box does not touch the video quality, it only takes a couple of seconds to add the Track, so I can test very quickly if the Audio delay is perfect or not.

Just in case, I extracted the sound from the other language like this:

avconv -i "AnotherSoundFile.mp4" Language.mp3

This would give me the mp3 sound track of that file and then I insert it to another file like I mentioned above.


MKV ONLY

mkvmerge GUI from mkvtoolnix-gui package.

enter image description here

  • Click add to select the video and audio files you want to merge.
  • In the Tracks, chapters and tags: box, select the new audio track (from the audio file you added), then you will be able to set its language (under General track options tab) and delay (under Format specific options tab).
  • Set the Output filename, then click Start muxing to save the video file.

You can also remove tracks and set the default audio track.


BOTH MKV and MP4

Just try using avconv (same as ffmpeg)

avconv -i FIRST_INPUT_FILE -i SECOND_INPUT_FILE -c copy -map 0:v:1 -map 1:a:12 OUTPUT_FILE

-i INPUT_FILE input file - may be almost any file (video and audio)

-c copy copies tracks to output without re-encoding them (fastest)

-map 0:v:1 -map 1:a:12 copies 2nd video track from 1st file AND 13th audio track from 2nd file

( 0(input file):v(video tracks):1(second track) )

Example:

avconv -i MY_MOVIE_3D.mp4 -i MY_MOVIE_WITH_DUBBING.avi -c copy -map 0 -map 1:a:0 OUTPUT_MOVIE.mp4

This command copies ALL tracks form MY_MOVIE_3D.mp4 AND 1st audio track from 2nd input file - MY_MOVIE_WITH_DUBBING.avi - into OUTPUT_MOVIE.mp4


you can use Yamb for editing mp4, which is like mkvmerge GUI but then for mp4box

or you can use MACHETE to edit MP4 files using a GUI to add / replace audio can also edit the video with it and edit other formats like MKV with it but its not free it costs $19.00