15

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

Is there any default tool to join videos?

19

Yes, you can join multiple videos into one file using default terminal commands. Using a simple cat will do want you want.

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

There is a big but here - this method will output the video1.avi header onto output.avi. Therefore, the header of output.avi is the same as video1.avi, so on most video players, it will look like video2.avi and videon.avi are lost - source 1, source 2.

To fix this, you need additional tools. There are many other terminal tools for joining movies that update the header as well. The most known video editing tools are mencoder (which is a part of 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 the short commands below.

The use and installation of mencoder or ffmpeg can be intimidating, but the video editing capabilities are the most powerful 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 one-liner 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 videos:

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

Or we can use ffmpeg to merge the two videos:

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

Note that you may need to escape the character "|" which is special for many shells, so

ffmpeg -i concat:video1.mp4\|video2.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.

1
  • Comments are not for extended discussion; this conversation has been moved to chat. – bmike Jan 18 at 20:55

You must log in to answer this question.

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