6

Possible Duplicate:
How can I merge or concatenate two or more MP4 files creating another MP4 file?

I recently ripped my DVD collection to play them on my media center PC, and several of them are two-disc movies (i.e. The Lord of the Rings). Since I ripped each DVD individually, that gives me two video files for some movies.

I am using Ubuntu Linux - how can I concatenate these two MP4/H.264 videos into a single MP4 video file? Preferably from the command line, and without re-encoding everything during the process (although I can try figuring out a video editor like Pitivi if that's the only solution.)

1

2 Answers 2

14

There are two ways you can do this.

  1. Using Mencoder
mencoder file1.mp4 file2.mp4 -ovc copy -oac copy -of lavf format=mp4 -o output.mp4
  1. MP4Box
MP4Box -add file1.mp4 -cat file2.mp4 output.mp4 

Note the use of '-add' for the first file and '-cat' for second file; if you mistakenly use '-add' for the second file - you will lose the first file's content.

4
  • 2
    I had to tweak these to get it to work: 1) mencoder can't use "-oac copy" on AAC streams for whatever reason; I have to tell it to re-encode on the fly. 2) I ended up using MP4Box, but the example provided overlays the two video and audio streams. The following command works (use -cat instead of -add for second file): "MP4Box -add file1.mp4 -cat file2.mp4 output.mp4" In the end it made the audio out of sync though, so I still have no good solution.
    – Jer
    Jan 3, 2011 at 16:35
  • I agree with @Jer, using the -add option multiple times adds multiple tracks - it does not create an appended video.
    – Brad Lee
    Dec 10, 2016 at 19:35
  • I have edited the post to change the second '-add' to '-cat' based on the comments by Jer above - after testing both options and confirming the comment was correct. (I wasn't able to test the audio option - since my files lacked an audio track)
    – monojohnny
    May 10, 2017 at 0:50
  • 1
    I was getting File not found: 'format=mp4'. I've had to remove the format=mp4 section (for mencoder).
    – Manolo
    Jul 25, 2018 at 9:33
1

Hunt down or build mp4box for your system. It's cli. I don't know of any linux guis for it, but I'm sure some exist.

Install MP4Box

sudo apt install gpac

Not the answer you're looking for? Browse other questions tagged .