2014-02-13

Linux: merge two mp4 files

You may want to combine multiple mp4/m4v video files into one continuous video. In order to do this, you need to install the gpac library of programs onto Ubuntu. Open up Terminal and run:

sudo apt-get install gpac

This will install the gpac library. One of the programs included with it is MP4Box, which you can use to concatenate the video files. If you get an error like MP4Box: error while loading shared libraries: libgpac.so: cannot open shared object file: No such file or directory, then you need to link the shared library to /usr/lib:

sudo ln -s /usr/local/lib64/libgpac.so /usr/lib/libgpac.so

Now to convert your files, add -cat filename.mp4 for each of your files to this command, with -new combinedfile.mp4 as your output, combined file:

MP4Box -cat vid1.mp4 -cat vid2.mp4 -cat vid3.mp4 -new combinedfile.mp4

Resource: www.thetechrepo.com (almost a 100% copy from there - however I use my site as my personal lookup)