I periodically make time lapse videos of random dumb things just for fun. I'm not about to pay for software to do it for me, when there are free ways to do it, which are easy with a little bit of knowledge. This post will cover just the technical aspect of turning jpegs into video.
There are two key commands (programs) I use, "convert" and "mencoder".
Convert is a command line program used to perform various conversions and transformations on images. It is part of the ImageMagik suite ( http://www.imagemagick.org/script/index.php ), and should be installed by default or readily available in most linux distros, and OSX. There are also binaries available for Windows, but my command as given will not work in Windows.
Mencoder is a command line program that transcodes video from one format to another. It is part of the mplayer project ( http://www.mplayerhq.hu/ ), and is readily available in most linux distros, and OSX. There are also binaries available for windows, and I think the command will run as given.
The first command, resizes a directory full of jpegs:
Explanation, for easier customization:
The second command turns a directory full of jpegs into a video.
Explanation, for easier customization:
My (admittedly boring, but luckily short) video created in this manner: http://youtu.be/r2QIMFg2Q4Q . One image every minute for just under six hours. 357 total images. I used to use a cheap Chinese intervalometer, but now now that it's pretty stable I use the one built into the MagicLantern firmware.
Hopefully this will be of some use to someone. If not, at least I have it documented for myself now, so I don't have to try and remember every time.
There are two key commands (programs) I use, "convert" and "mencoder".
Convert is a command line program used to perform various conversions and transformations on images. It is part of the ImageMagik suite ( http://www.imagemagick.org/script/index.php ), and should be installed by default or readily available in most linux distros, and OSX. There are also binaries available for Windows, but my command as given will not work in Windows.
Mencoder is a command line program that transcodes video from one format to another. It is part of the mplayer project ( http://www.mplayerhq.hu/ ), and is readily available in most linux distros, and OSX. There are also binaries available for windows, and I think the command will run as given.
The first command, resizes a directory full of jpegs:
Code:
for FILE in IMG*.JPG ; do convert $FILE -background black -gravity center -extent 5184x2916 -resize 4096x2304 C4$FILE ; done
Explanation, for easier customization:
Returns the name of one file at a time that match "IMG*.JPG" (like IMG_4786.JPG), and feeds it into convert.for FILE in IMG*.JPG ; do
Convert command, and the variable representing the input file name.convert $FILE
If the image will be padded, this sets what color the background will be, and how the image will be justified.-background black -gravity center
This will either crop, or pad the image to the correct aspect ratio before it's resized. Think of it as changing the canvas size in Gimp (or Photoshop). My original image size is 5184x3456, to get that to the desired aspect ratio of 16:9, I can either pad (letterbox) it by setting the extent to 6144x3456. Or crop it by setting the extent to 5184x2916.-extent 5184x2916
Resizes the image to the desired size for the movie. Since we got the image in 16:9 format with extent, you can pick any 16:9 format. i.e. 1920x1080 (1080p), or 4096x2304 (4K that Youtube uses).-resize 4096x2304
This is the output file name, which I'm taking the variable for the input file name ($FILE), and adding "C4" to the beginning (like C4IMG_4786.JPG).C4$FILE
Tells it to go back to the beginning of the line, and grab the next file name.; done
The second command turns a directory full of jpegs into a video.
Code:
mencoder "mf://C4IMG*.JPG" -mf fps=30000/1001 -o 4Ktest.avi -ovc lavc -lavcopts vcodec=mjpeg
Explanation, for easier customization:
Tells mencoder to use all files that match "C4IMG*.JPG" (like C4IMG_4786.JPG) to create the video.mencoder "mf://C4IMG*.JPG"
Sets the output frames per second. You can use integer values like 10, 24, 25, 30; or fractions for the exact fps values like 30000/1001 for 29.97fps.-mf fps=30000/1001
Set the output filename.-o 4Ktest.avi
Set the output video codec to mjpeg.-ovc lavc -lavcopts vcodec=mjpeg
My (admittedly boring, but luckily short) video created in this manner: http://youtu.be/r2QIMFg2Q4Q . One image every minute for just under six hours. 357 total images. I used to use a cheap Chinese intervalometer, but now now that it's pretty stable I use the one built into the MagicLantern firmware.
Hopefully this will be of some use to someone. If not, at least I have it documented for myself now, so I don't have to try and remember every time.