How to create a timelapse video with mencoder

While OSX 10.6 would come with the Pro version of Quicktime that can create timelapses via a fancy GUI etc. I’m currently running 10.5, so Quicktime Pro was out of the question. Of course, as an old Linux user I’m familiar with the command-line and have some experience in getting mplayer / mencoder to do what I want it to.

I’m using this to document my whole process. To see the final scripts / options / tools, you’ll need to skip to the end.

So Google to the rescue and I came up with a good starting point for creating the movie from my resized images. Santtu Pajukanta has a detailed description of how he created a timelapse.

However, since I didn’t want to package with Matroska because I wanted to later edit the videos I looked around a bit more and found some info on how to package it all into a mov-file. I basically adapted code from Trevor Shannon to do this.

At this point I had a scripted setup that took the FullHD sized images and made two passes over the data and created a timelapse movie. I also parametrised the framerate because at this point I was still playing around with different framerates to see which one would work the best. Unfortunately, the end result was quite poor in quality, so I went looking for more options on how to create the movie. I also had a hard time playing the movie in anything other than VLC on my Mac.

So some more digging around pointed me towards using MP4Box from the Debian package gpac to box the movie. I also adapted the three-pass approach used in ripping to encode the movie as well. Unfortunately again the end result wasn’t exactly what I needed. While the quality was good, end movie size was huge (around 500 MB for a minute of video) and playback wasn’t smooth on either Mac we have in the house (a two year old iMac 24 and year old MacBook).

So I started looking into the bitrate I was using and found the following formula:

optimal_bitrate = 50 * 25 * width * height / 256

For some reason this formula led to an impossible large bitrate that even mencoder complained about. Finally I settled for 80 000 kbit/s which seemed to do the trick well enough.

But now I still had video that was large and didn’t work smoothly. However, I figured that this was still raw footage and after editing each day’s video together in iMovie I’d get a usable result. And then I found out that the movies I’d made could not be imported into iMovie. At this point I’d already used a couple of weeks to create the various versions of the movies.

So, a bit more digging around Google and I finally found a email list posting that gave options on how to create a raw video with mencoder that can then be edited with iMovie. I adapted the command in the posting to suit the creation of a timelapse and ended up finally with:

mencoder ‘mf://1080p/*.JPG’ -ovc x264 -of lavf -lavfopts format=mp4 -x264encopts crf=18:nofast_pskip:nodct_decimate:nocabac:global_header:threads=4:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:threads=auto:bitrate=${BITRATE} -nosound -noskip -mf type=JPG:fps=${FPS} -o $FINAL

Note that this does not scale the images at all. I prescaled and cropped the images to 1920×1080 using other tools.

In the final version I used a bitrate of 80 000 and fps of 24. This resulted in around 500 – 600 MB videos for each day (around one minute of footage). I then imported these videos into iMovie and created some titles and credits and added some music to the whole thing. From iMovie I exported everything as a HD movie (720p) and the end result was a bit over eight minutes of footage and a file size of 596.1MB. More information on the final timelapse in this post.

All in all, it was a good learning experience and I noticed that iMovie won’t do if I want to create FullHD footage once I get the 7D. But that’s an issue that can be solved then.

Suviseurat 2010: How 70 000 came and went – a timelapse of eight days

The laestadian summer services descended upon the fields around our house about a month ago. We’d been watching the buildup of the area over the last months and I thought I’d record a timelapse of the build and event itself. In fact, there’s a post detailing the beginning of the project. Unfortunately, due to various circumstances I wasn’t able to document the whole process – not that anything interesting happened in our field of view most of the time.

But, starting from midnight 29.6.2010 to the end of 6.7.2010 I set our old Canon 300D to shoot a wide-angle shot of part of the area. While the event itself officially started on 1.7.2010, the 29th was the day when the logistical organization started functioning and people started to arrive. During those eight days, the 160 hectares (395 acres) of fields around our house were the home for 70 000 people. Most of them either had their own RVs or caravans although some rented houses and cottages in the area and were day visitors.

I set up the camera to shoot a picture every minute, which gave me around 1400 pictures per day. To save space, I selected the image size that was closest to FullHD resolution and finally just cropped the images a bit. Not every single minute of the day was captured since we had to switch batteries in the camera and a thunderstorm forced us to switch computers commanding the timed shooting. But we got close enough to a minute of footage from each day (24 frames per second).

Without further ado, here’s the final product:

There are some brief appearances of us and our dogs in a few frames…

Creating the timelapse was very much a learning experience. I’ve documented the technical challenges in creating the video itself, but there were many other challenges as well. Some of the lessons I’ve learned can be summed up in the following bullet points:

  • First of all, any timelapse project that spans more than a few hours really needs a continuous power supply for the camera. Swapping batteries creates lags that are unfortunate.
  • If you’re shooting from inside through a window, watch out for reflections. You sure can see plenty in the timelapse
  • Finding a good framerate for the final video is hard and depends on the use.
  • Creating the video takes a lot of time.

But, it was a good learning experience and hopefully at least a few viewers will be able to enjoy the end result.