Time-lapse photoblography

Andrew Booker 2008-04-01 00:01:00

A couple of weeks ago I set up some bits of Visual Basic software to download satellite images of clouds. These are ticking over nicely gathering more pictures every day. Meanwhile I've successfully hacked together some C++ to build AVI files out of these images using the Microsoft Win32 Multimedia libraries. I thought I was going to have to try and build the files myself from scratch using their AVI file format, but using their own functions is much easier. It's also much nicer than using their Movie Maker, because I can build my AVIs automatically, at whatever frame rate I like. The next step is to insert the image processing, of which thanks again to Microsoft there is a fair amount I can code myself in C++. The rest is for Photoshop, which as I hinted last time can be automated via COM. More about that when I get to it.

All of which makes for jolly good geeky fun for graphics initiates such as myself. Said fun need not lie in weather satellite imagery alone. Now that I can automate turning stills into movies, I've been getting stuck into some kindergarten time-lapse photography. Hardly breaking new cinematic ice-shelves, but continuing with the weather theme, I've started by pointing the camera at the sky.

My plan is to capture an entire day of sky movements, and play it back in the space of... good question. Let's say I wanted an incredibly fast playback, such as the sun moving across the sky at roughly the same speed as the second hand moves round the clock. A couple of weeks or so after the spring equinox as we are, that roughly means 12 hours reducing to 30 seconds. A playback rate of 24 fps (frames per second) would mean I need to take one image per minute, 720 in all.

How do you take those pictures? I guess if you have a clever enough camera it will do it for you. I started by using a webcam and some really dirty Visual Basic.

Webcams can either supply video or still images. My webcam setup seems only to allow saving to AVI, with no compression. At 640x480 that means about 1MB per frame, which at the lowest frame rate of 5fps means about 300MB per minute, well over 400GB for 12 hours. Even if I have a hard disk to fit all that on, I would then need to spend some phenomenal processing time throwing away 299 frames out of every 300. So I'm not looking at video as the best image capture option.

My webcam interface has a control panel that lets you take still pictures, which it immediately compresses into jpegs somewhere on the hard disk, after which you can save them to wherever you like. Sucking the image off the camera down the USB port and compressing it onto disk takes less than a second, but copying it to your folder and then deleting it from the working directory seems to add another several. Even so this is usable for taking pictures at a rate of one a minute, it's even OK one every 10 seconds. However, unless you copy-and-delete picture by picture, it names them for you as 001, 002, 003 etc. Techies will quickly spot a pathological case after 999 files.

So, what I did was automate taking a picture and saving it and deleting the original into a 10 second loop. I used a Timer in VB and some yucky automation. The webcam application is a GUI and was not designed for automation, however, if everything you want to do can be achieved using keystrokes, you have a chance. In VB you can activate the application as a target window and fire keystrokes at it. It's a small pain to work out what those keystrokes are, and it needs the appropriate delay of a few seconds here and there to allow the thing to process, but I eventually got it working... sort of. I took roughly 1000 images of dull grey cloud over about five hours, amounting to mere 13MB. The files were between 10 and 17KB each, which sounds like major compression and sacrificing of image quality, but remember these are pictures of grey clouds, with very little depth of colour, hence they compress very well. The trouble was they weren't turning up at regular intervals: between 15 and 20 seconds, when the gap was supposed to be precisely 10 seconds. This is what you get when you do stuff in Visual Basic. The other problem I had with this was that as it got darker, the webcam shooter seemed to flake out and not save the images properly. Sadly I didn't spot either of these problems because once the webcam automation is going, you have to leave your computer alone, otherwise you change the active window, the keystokes go to the wrong places and all sorts of comedy arises.

If I can't get the interval down to exactly 10 seconds, and I'm feeling really brave, I might try and write my own image grabber for the webcam in C++, although life is feeling a little bit too short for that right now.

So far, so much practice with time-lapse photography. If I can get a regular frame rate capture, one day when the weather forecast is a good mix of sun/cloud, I'll kick it off early in the morning, go into the office, and when I come back in the evening I should have a thrilling catalogue of a semi-overcast day in England. The interest lies mostly in positioning the camera well. Altitude is essential. Get the camera as high as possible, and point it at the horizon, so that you get the longest travel in the cloud movements. Which means I either need to shove it up the chimney or climb up onto the roof. It is good to get a bit of ground-level interest too. People and traffic make great subjects for time-lapse or fast forward video. Perhaps I can park the car somewhere busy but safe and rest the camera inconspicuously against the glass.

Speaking of cars, I went for a drive on Saturday morning with the camera mounted on top of the dashboard.

My camera is a Panasonic NV-GS75 that records to DV tapes. [After recording, you can copy the data via Firewire to a laptop.] That orange thing it's sitting on is a MonsterPod. It has a special gooey polymer that will stick to anything, possibly too well. You just put it the dashboard and it's stuck fast., and has to be peeled off. Brilliant. I was trying to do car videos like this a year ago. The only way I could do it was sit in the passenger seat and try and hold the camera as still as possible for an hour. If only I'd walked into a camera shop.

It worked very well with its ingenous new mounting device. Those DV tapes can fit an hour (or more in slow-mode), and what I want at the end is to vroom the whole trip into a couple of minutes. If all these time-lapse ideas seem to be coming up a bit short in the finished product, when I have a two-hour gig to fill, you'd be right. But let me tell you my route.

See what I did there? I went through the Wanstead underpass twice. When you take a video camera with automatic light sensitivity down a tunnel, what happens as you come out the other end at 40 mph is that it can't adjust to the daylight quick enough, and you get a momentary white glare. When I'm editing, at exactly that point, I'm going to loop back to when I took the underpass the first time round. I was careful to stick in the slow lane both times, though it probably wouldn't matter. Seamless video looping.

That should be good, but what I really want is to go out at night, along streetlit bits of motorway, because those look great. That might be another job for later this week. If I want a loop, the journey needs to be short enough to fit on one DV tape.

That is exactly what has prevented me from taking the glaringly obvious choice for a looped road trip, the M25. I've never been sad enough to travel all the way round at once, but I reckon I can expect a two-hour trip. That is more than can fit on a DV tape, but thanks to my experiments with time-lapse webcam shooting of dull-as-pigeon-feathers British weather, I may have an alternative solution... provided I can take the pictures fast enough.

Suppose I want to condense two hours into 5 minutes at a playback rate of 24fps. For that, I need to shoot one image per second. By the looks of things, over a short period this should be possible, it's the saving (copying) of the images that's taking too long. Over two hours at that rate I will amass 7,200 images, which exceeds the three-digit naming capability of the webcam snapshooter without saving. Over the next few days I'll either experiment and see what it does, or put the kettle on and start trying to write my own video capture utility. Failing both, it's the Panasonic. Pah, I would only be throwing away 23/24ths of the data.

BTW, before the greener amongst you get upset, I will be offsetting the carbon footprint of these well-trodden visual machinations by planting plenty more herbs in the back garden.

Geek weather << | >> Time-lapse in the car