Creative Solutions


Append Videos With Mencoder « Behind the Scenes

Append Videos With Mencoder

November 10th, 2009

Mencoder, the free audio / video transcoding software packaged with MPlayer, offers a free command line (CLI) method for combining many video clips into one.

Why would you choose this over the multitude of free GUI transcoding programs out there?

  • Mencoder is super-fast
  • Allows the process to be scripted
  • Wide range of codecs
  • Cross-platform compatible

Once you get the feel for it, you can append videos much quicker with Mencoder than a more “user friendly” GUI program. And, it works on Linux, Macintosh, and Windows machines, so you don’t have to learn 3 different programs if you work on multiple operating systems.

Here’s the basic format of a Mencoder append command:

mencoder -oac copy -ovc copy -o 'combined_clip.avi'
'clip1.avi' 'clip2.avi'

Simple as that. The breakdown is as follows:

  • -oac
    Tell Mencoder what audio codec to use. For a complete list of options, check out the Mencoder documentation. In this case we have simply used “copy”, which will keep the current audio codec the same without transcoding (this option should only be used if the audio codecs are the same for all the clips).
  • -ovc
    Tell Mencoder what video codec to use. Otherwise, same as above.
  • -o
    Define the paths to input and output files. First list the output filename, then all the clips in the order which they will be appended.

Knowing this, it is easy enough to script the process. Say I have a whole directory of video files that I want to combine (ex: VID001.AVI, VID002.AVI, VID003.AVI, etc.). I could use the following ruby script to string them all together in their numbered order:

vlist =
vpath = "/path/to/my/video/directory/"
vdir =
vdir.each do |v|
  if v.include?(".AVI") == true
    vlist << "\'#{vpath}#{v}\' "

cmd = "mencoder -oac copy -ovc copy -o \'combined_clip.avi\'
system cmd

Save the script as VAppend.rb and run it like so:

ruby VAppend.rb

(you must be in the same directory as the script in order to run it with the above command)

Final Notes
The command in the first code box is all one line, and the line in the second code box starting with "cmd =" is also all one line that continues onto a second for formatting purposes (in other words, #{vlist}" belongs at the end of the previous line).

2 Responses.

  1. Spyware News says:

    Just want to say thank you! for all the great info found on your site, even helped me with my job recently :) keep it up!

  2. I like this web really much.

    This is such a outstanding web.
    And it is not like other money orientating website, the information here is genuinely important.

    I am definitely bookmarking it as well as sharin it with my friends.


get a webcast quote
read our case studies
view samples