# Time Lapse



## bvukich (Jan 14, 2012)

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:

```
for FILE in IMG*.JPG ; do convert $FILE -background black -gravity center -extent 5184x2916 -resize 4096x2304 C4$FILE ; done
```

Explanation, for easier customization:


> for FILE in IMG*.JPG ; do


 Returns the name of one file at a time that match "IMG*.JPG" (like IMG_4786.JPG), and feeds it into convert.


> convert $FILE


 Convert command, and the variable representing the input file name.


> -background black -gravity center


 If the image will be padded, this sets what color the background will be, and how the image will be justified.


> -extent 5184x2916


 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.


> -resize 4096x2304


 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).


> C4$FILE


 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).


> ; done


Tells it to go back to the beginning of the line, and grab the next file name.



The second command turns a directory full of jpegs into a video.

```
mencoder "mf://C4IMG*.JPG" -mf fps=30000/1001 -o 4Ktest.avi -ovc lavc -lavcopts vcodec=mjpeg
```

Explanation, for easier customization:


> mencoder "mf://C4IMG*.JPG"


Tells mencoder to use all files that match "C4IMG*.JPG" (like C4IMG_4786.JPG) to create the video.


> -mf fps=30000/1001


 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.


> -o 4Ktest.avi


 Set the output filename.


> -ovc lavc -lavcopts vcodec=mjpeg


 Set the output video codec to 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.


----------



## JR (Jan 14, 2012)

bvukich, will those command work with a PC or only on linux or Mac?


----------



## bvukich (Jan 15, 2012)

JR said:


> bvukich, will those command work with a PC or only on linux or Mac?



The mencoder command should work as is. The convert command is actually a single line bash script, and will not run in windows. But there are probably other ways to do the same thing.


----------



## JR (Jan 15, 2012)

Ok thanks. I will look into it...


----------



## Axilrod (Jan 18, 2012)

You know you can use Quicktime 7 to do this without scripts....go to "create new image sequence" and you select the folder with all of the pics in it and select a framerate and you're good to go.


----------



## TexPhoto (Jan 18, 2012)

Axilrod said:


> You know you can use Quicktime 7 to do this without scripts....go to "create new image sequence" and you select the folder with all of the pics in it and select a framerate and you're good to go.



Yea this is a very easy way to do it. I like to make my movies full size: 5184x2916, and then in iMovie you can zoom and pan inside the time lapse.


----------



## Ryan Ron (Sep 19, 2012)

If you want to just alter batch images to usable image format, then Image Converter software is a simple and quick way to a lot speed up picture's file type changes in just a small number of clicks. As a batch image converter I also use ReaConverter software with its batch editing mode.


----------

