September 19, 2014, 02:28:26 PM

Author Topic: Time Lapse  (Read 4112 times)

bvukich

  • Spam Assassin
  • Administrator
  • 5D Mark III
  • *****
  • Posts: 730
    • View Profile
    • My (sparse) ZenFolio Site
Time Lapse
« on: January 14, 2012, 03:06:12 AM »
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:
Code: [Select]
for FILE in IMG*.JPG ; do convert $FILE -background black -gravity center -extent 5184x2916 -resize 4096x2304 C4$FILE ; done
Explanation, for easier customization:
Quote
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.
Quote
convert $FILE
Convert command, and the variable representing the input file name.
Quote
-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.
Quote
-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.
Quote
-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).
Quote
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).
Quote
; 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.
Code: [Select]
mencoder "mf://C4IMG*.JPG" -mf fps=30000/1001 -o 4Ktest.avi -ovc lavc -lavcopts vcodec=mjpeg
Explanation, for easier customization:
Quote
mencoder "mf://C4IMG*.JPG"
Tells mencoder to use all files that match "C4IMG*.JPG" (like C4IMG_4786.JPG) to create the video.
Quote
-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.
Quote
-o 4Ktest.avi
Set the output filename.
Quote
-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.

canon rumors FORUM

Time Lapse
« on: January 14, 2012, 03:06:12 AM »

JR

  • 1D X
  • *******
  • Posts: 1244
    • View Profile
Re: Time Lapse
« Reply #1 on: January 14, 2012, 08:50:03 AM »
bvukich, will those command work with a PC or only on linux or Mac?
1DX, 24mm f1.4L II, 35mm f1.4L, 50mm f1.2L, 85mm f1.2L II, 135mm f2L, 24-70mm f2.8L II, 70-200mm f2.8L IS II :  D800, D4, and a whole bunch of Nikon lenses

bvukich

  • Spam Assassin
  • Administrator
  • 5D Mark III
  • *****
  • Posts: 730
    • View Profile
    • My (sparse) ZenFolio Site
Re: Time Lapse
« Reply #2 on: January 14, 2012, 11:34:37 PM »
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

  • 1D X
  • *******
  • Posts: 1244
    • View Profile
Re: Time Lapse
« Reply #3 on: January 15, 2012, 09:07:31 AM »
Ok thanks.  I will look into it...
1DX, 24mm f1.4L II, 35mm f1.4L, 50mm f1.2L, 85mm f1.2L II, 135mm f2L, 24-70mm f2.8L II, 70-200mm f2.8L IS II :  D800, D4, and a whole bunch of Nikon lenses

Axilrod

  • 1D X
  • *******
  • Posts: 1373
    • View Profile
Re: Time Lapse
« Reply #4 on: January 18, 2012, 10:55:15 AM »
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. 
5DIII/5DII/Bunch of L's and ZE's, currently rearranging.

TexPhoto

  • 1D Mark IV
  • ******
  • Posts: 920
    • View Profile
Re: Time Lapse
« Reply #5 on: January 18, 2012, 12:26:51 PM »
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

  • SX50 HS
  • **
  • Posts: 1
    • View Profile
Re: Time Lapse
« Reply #6 on: September 19, 2012, 01:54:29 PM »
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.

« Last Edit: September 24, 2012, 08:30:35 AM by Ryan Ron »

canon rumors FORUM

Re: Time Lapse
« Reply #6 on: September 19, 2012, 01:54:29 PM »