Timelapse photography has always fascinated me, you have but to drop by Vimeo or Youtube and be blessed with impressive videos - I would mostly stick to Vimeo from the looks of the Youtube results ;) . Now, some cameras offer some type of timelapse settings, but from what I've seen (on a few cameras, I'm hardly a man with a deep knowledge of the market) they offer limited frame counts with not so short intervals (minutes, instead of seconds), so for a while I wasn't very tempted or motivated to try and timelapse myself, but recently I actually found a good mix of software that not only revived my interest in timelapse, but empowered me and made an old camera come to life and be useful again :)
So , onwards to my simple recipe for Timelapse videos :)
So, I'm a SLR fan and I admit, I tried to timelapse with my old Canon 300D but as the 99 Error Code of Unknown Death started to flash more and more often, I tried it once, and aborted at the though of the old and battered shutter simply dying for a simple test. Now, luck would have it that I was cleaning my closet and I found my old Canon Powershot S70, that for some reason (at the time) went bad and seemed to be non-working - it was taking terribly dark pictures, and no, it wasn't me being silly .
I took it, charged the battery, found a USB cable, plugged it in and with the help of Mister Ingredient #2 .. BOOM :) it worked like a charm, and at least it's one shutter I don't have to worry much about :)
I had some computer troubles, a 3 year old Windows XP installation not filled with Spyware and Viruses, but certainly filled with a lot of other things developers tend to accumulate :) , and I felt the need to change and jumped onto the Ubuntu bandwagon - a post for later perhaps :) - with great success and personal joy.
A result of that jump was that I stumbled into gphoto - yes, I admit it, apt-get ease of install actually makes me find new stuff more easily. Now, gPhoto is a "set of digital camera software applications for Unix-like systems" that supports more than 1300 cameras, and while this may sound vague, a quick look over the manual - or command line help - shone a light on me, a light in the form of "--capture-image" and "interval" :)
So what basically happens is, I could now hook up a Camera via the USB port, call up gPhoto2 and tell him to capture images forever (or with a limit of frames) within a timeinterval that it will try to keep as long as the camera helps :) .
We have control, we get our computer taking care of our camera and telling it to take pictures from time to time, with settings that we control, but we'll just have a bunch of images, so we need something else
Now, as luck would have it I was in the middle of a project that involved video encoding and a fair amount of FFMPEG, so I knew this would be my non-professional tool last piece of the puzzle, as we can take a bunch of images and tell FFMPEG to make a movie out of them.
The project I was doing needed to encode files using VP8, so if you want that, please, visit this tutorial on how to get FFMPEG correctly installed, It Just Works (tm) and you'll be WebM'ing in no time
The settings change according to what your needs, camera capabilities and type of scene, I'll give you a general run down of the commands and pipeline I have, I'll show you some examples but after that, please, let us discuss :)
So, take your Digital Camera, put it on a tripod (you won't be holding it perfectly still for hours, now will you?), connect it to your PC (or Mac if that's your fancy) and get a terminal open for ...
gphoto2 --capture-image --interval 15
This will tell gphoto2 to initialize the camera and get it cracking pictures every 15 seconds. 15 seconds incidentally is no random number, for my Powershot, it's the fastest I can go while taking pictures with enough quality for a Full HD movie export (1920x1200) , if I want more I need to go onto lower resolutions.
I'll leave the camera up for a while, usually for as long as the battery lasts ;) , but the math is sort of easy to do, if you want a 30 fps movie, you need to take 30 pictures for each second of video. If, for instance you want a full minute that would mean 1800 pictures, at a 15 seconds interval that would mean .................... 7 hours and 30 minutes of picture taking :) , how cool is that? :)
So, next up, I download the pictures to my computer, put them in a directory and prepare them for FFMPEG. Now, this would be the time to mess around with the pictures, maybe resize them or crop them (FFMPEG can do that for you), but more importantly adjust Brightness, Contrast, Saturation, perhaps mess around with Levels, but keep in mind that you'll probably want something that can be run against a batch of pictures so, don't overdo it :)
Ok, preparing the files for FFMPEG means getting them with a sequential naming scheme so FFMPEG can cycle and encode them into a movie file. For this I use a bit of bash scripting that I found online (sorry, no reference :( ) and that looks like this
x=1; for i in *JPG; do counter=$(printf %04d $x); ln "$i" ./tmp/img"$counter".jpg; x=$(($x+1)); done
What this does is go through all files that have "JPG" inside a directory (my camera saves files with a capital JPG extension, but feel free to adjust this to your settings) and create a link inside a folder (tmp) with four digits (change this accordingly - %04d) . By the end of this, we have a nice little directory with 0001.jpg all the way to xxxx.jpg in sequential order for mister FFMPEG.
So, having this, all I need to do is tell FFMPEG to grab the files and pack them into a video file, a hd1080 WebM encoded file :) with the following command:
ffmpeg -f image2 -i img%04d.jpg -s hd1080 -r 24 output.webm
This takes a while, but by the end of it - assuming you had no errors breaking the process - you'll have your very own Full HD - VP8 video ready to Youtube uploading :) .. or whatever you do with video files :)
I'll leave you with three initial attempts, none particularly brilliant, I was furious about trying this out and I hardly remember the settings but it will give you an idea, and if you look at the kitchen one, you'll see that different types of scenes require different settings, in that case the interval was too long (but I remember using 15s for it, so it needs to be much faster) for anything useful to come out.For city or outside scenes, I think doing it by night adds an interesting and much appreciated effect, slow exposure, you'll get light streaks that make the scenes more fluid, in the day scenes it's easy to spot objects jumping around.
All of this is a first attempt at things, I think the pipeline is ok, but I think that either by using professional software or by adding something to the mix, we can generate some in-between frames to both enrich the movie but also make it longer and have a better control of the timelapse rate.
I hope this can be useful in anyway to you, I know all these factors combined motivated and empowered me to experiment with timelapse, and I wanted to share it, but it's only one way, and I'm sure there are countless, so if you know other techniques or have more ingredients to add to the mix, please please please, let's talk about it :D