[Note: this post embeds some very large gif files. Cancel now if on a slow connection…]
A while ago, I was playing with imagemagick (it’s an amazing tool) and trying to make animated gifs. It worked, sort of. One of the things I’d been meaning to try for a while – but never quite got around to – was animating webcam images. Last week, I finally got around to it.
At work, we have a webcam pointed at the Halley VI Antarctic station. It’s turned on year-round, sending back one picture hourly, fairly reliably. Being on a pole in the middle of Antarctica, it’s also free from the major problem that arises when trying to animate webcams – someone moving them around every now and again.
And the pictures are remarkable. Halley VI is an imposing-looking building at the best of times, but on a dark morning, looming out of a snowstorm, it’s like something from a film.
Twenty days in late November 2014 – note the sun tracking by the top of the image each day.
Ten days at the end of January 2015, with 24-hour daylight and a lot of activity around the station.
One shot each day (at 12.30pm UK time, so about 10am? local solar time), chained over 373 days – so slightly more than a full year. It opens in mid-November 2014, about the time the first aircraft arrive and the summer activities begin, passes through the (very busy) summer season, then quietens down as winter approaches. The nights appear as momentary flashes, then get longer and longer until they’re permanently dark in June/July. Then it slowly returns…
The code for this is pretty simple. Assemble all the files in a single directory – either sourced locally or downloaded with wget/curl – and ensure they’re named in a sequential way. All of these, for example, were of the form
halley-2015-01-02-12-30.jpg – the 12.30 shot on January 1st.
Make sure to delete any that returned error messages in the download or are below a certain size. I had one or two zero-content frames that made the system hiccup a bit, and
find images/*.jpg -size 0 -delete is good for handling these.
convert -resize 500x500 images/*.jpg animation.gif
That’s it. The resize is to prevent it getting disgustingly large; adding
-optimize shaves a little more off the filesize. Even so, though, you’ll find that assembling more than a few hundred frames makes your system quite unhappy (it may lock up) and the resulting gif is far too large to be useful. For the images above, some examples of filters on the merge:
convert -resize 500x500 images/halley-2015-01-2*.jpg animation.gif
convert -resize 500x500 images/*12-30.jpg animation.gif
– so it only pulled together the frames we were interested in. Of course, you could do a simpler (or more complex) merge by copying the relevant ones to a separate directory and just merging everything there.
Given the size problems of gifs, making a larger one is probably best left to video. Here’s the entire year, using every frame (23 MB):
Note how short the day/night pulses get towards the ends of the spring/autumn.
For this, you don’t have to resize, and you can produce it at the full size of the webcam images (in this case, 1920×1080):
mencoder mf://images/*.jpg -mf w=1920:h=1080:fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o halley.avi
The key part here is the images list (you can filter again as before) and the
fps=25; I ran it at various speeds and found 40fps seemed to be a happy medium. 25fps is just a little jerky. The version above is reduced to 512px wide:
mencoder mf://images/*.jpg -mf w=1920:h=1080:fps=25:type=jpg -vf scale=512:288 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o halley.avi