I would like to join mp4 videos like I join pdfs by pdfjoin.

Is there any default tool to join videos?

share|improve this question
up vote 10 down vote accepted

Yes you can join multiple video's into one file using default terminal commands. Using simple cat will do want you want.

cat video1.avi video2.avi videon.avi > output.avi

There is a big but here. Using the previous mentioned method will output the video1.avi header on output.avi. Therefor the header of output.avi is the same as video1.avi, so on most videoplayers it will look like video2.avi and videon.avi are lost, source1, source2.

To fix this you need additional tools. There are great other terminal tools for joining movies that update the header as well. The most known video editing tools are mencoder (which is a part mplayer) and ffmpeg. Both have an enormous amount of options and settings and it is beyond this forum to go into much detail, but I will give a short commands below.

The use and installation of mencoder or ffmpeg can intimidating, but the video editing capabilities are most powerfull I have encountered so far. As the installation from source can be a hassle for native OS X users I advise you to use Homebrew.

To install these tools using Homebrew run this oneliner in your terminal:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Homebrew is now installed, it is wise to follow the installer's suggestions after installation. Now we install ffmpeg and mencoder using brew.

brew install ffmpeg mplayer

Now we can use mencoder to merge the two video's:

mencoder -oac copy -ovc copy -idx -o output.mp4 video1.mp4 video2.mp4 video3.mp4

Or we can use ffmpeg to merge the two video's:

 ffmpeg -i concat:"video1.mp4|video2.mp4" -codec copy output.mp4

You specifically ask for .mp4 files. mp4 is a container format, it is possible that the default installation of ffmpeg or mencoder does not have the correct coding/decoding ('codecs') packages by default and that you need to install these separately. But that is beyond the scope of this topic.

share|improve this answer
    
Note that you may need to escape the character "|" which is special for many shells, so ffmpeg -i concat:video1.mp4\|video2.mp4 – CousinCocaine Jun 16 '14 at 10:18
2  
Using single quotes ('') might be easier than escaping the pipe character. In the command used in the answer, it doesn't matter either way. – patrix Jun 17 '14 at 9:12
    
Very good answer with clear explanation. Thank you! – Léo Léopold Hertz 준영 Oct 8 '14 at 20:49
1  
Tried installing Homebrew using terminal command as described in this answer and got "The requested URL returned error: 400 Bad Request". As per Homebrew webpage, the new terminal command is /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/in‌​stall)" – Sparky Jul 25 '16 at 23:44
    
@Sparky go to brew.sh for install instructions. – CousinCocaine Jul 26 '16 at 6:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.