Monday, February 4, 2008

Image sequence to movie : Mencoder

UPDATE: I have switched over to ffmpeg.

Mencoder works on both Linux and windows and is a great option for the simple, repetitive task of taking an image sequence dumped from a data analysis program and converting it into a movie (to animate the data) [Mencoder help page: movie from image frames].

What I end up using is the following command

mencoder -audiofile sound.wav -oac copy mf://*.jpg -mf fps=25 -ovc lavc -lavcopts vcodec=wmv2 -of avi -o output.avi -vf scale=800:600

-audiofile sound.wav -oac copy tells mencoder that the audio file to attach to the animation is called sound.wav and I want it copied as is (no change in encoding) [more here, and here]. You can omit this if there is no audio file

mf://*.jpg -mf fps=25 -ovc lavc -lavcopts vcodec=wmv2 tells it to take all the .jpg files in the directory and make a movie at 25fps using the microsoft wmv codec

-of avi -o output.avi -vf scale=800:600 The output file is called output.avi and has a size of 800 x 600 pixels in avi format. Omitting -vf scale will keep the original size of the images

Install notes:
  1. Download the binaries [mplayer.hu]
  2. Unzip to a directory /my/mplayer/
  3. Add the root to your path

1 comment:

  1. This works great - thanks for the tip.

    ReplyDelete