Wednesday, 4 June 2014

How to make timelapse trail cam videos

I've had my Trail Camera sited in a variety of places in my garden for a few months now, with varying degrees of success.  The camera is described in this post, and can be configured to capture either video or images.

The theoretical maximum resolutions of each mode are:
Video: 640 x 480
Image:  8 Mega Pixels - I'm not sure how this translates to an actual resolution

It has night and daytime modes, Night time illumination is achieved via the in-built infra-red (IR) LEDs that surround the camera.  Not surprisingly, captured image quality is much better in daylight.  The following images are the full 8MP.

It also has a weird intermediate mode, which seems to be in low light where the IR illuminators haven't come on, however its IR filter has come off which give some interesting images.  In the following set, the top image is low light in the evening.  IR illuminators havent come on, but the internal IR filter is off the camera leading to this 'ghostly' image.  The one below is a true night time image - illuminated by the camera's IR LEDs.

Interestingly, it looks like the image resolution is automatically dropped for night time images as the field of view seems narrower - these two images are taken approx 6 hrs apart without the camera having been moved.  For the best quality images I've found that a cloudless sky with a full moon gives the best images, producing a more evenly lit scene.  My favourite bit of footage so far is that of a badger mother + cub tucking into a slow worm.  I've uploaded the original clip here:

Pros & cons
Using a trail cam is a great way of observing wildlife behavior that you wouldn't normally see (I did cheat a bit and put down peanuts in the area in front of the camera an in the long grass to keep the badgers interested).  One limitation is that once its set to video or images, it stays that way until changed.  A cool option would be to have it take a high res image, then capture a video clip - unfortunately not an option.

Make a time-lapse of still images
I've found that on some nights I have a load of okay-ish images, but nothing that would win any prizes.  I took a leaf out a stop-frame animation project I did with one of my kids on her Raspberry Pi.  I used the same approach generating the video in a post I did on how to make time lapse videos of clouds.
The advantage of doing this is that you effectively increase the resolution of the video, since I'm using the higher resolution still images.  The result is kind of jerky but I think its an interesting effect.  The following clips are encoded at 4fps:

To achive this, I've used mencoder in Ubuntu - but this should work on a mac PC too.  There's an install guide for mencoder on the Rapsberry Pi here, but you're better off running in a full-fat linux system such as Ubuntu or on a Mac PC.

ls *.jpg > list.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o video.avi -mf type=jpeg:fps=4 mf://@list.txt

Selection of 'Time-lapse' videos from Trail cam still images: 
These are best viewed full-screen with HD option selected

1) Adult female badger 'in-milk'.  You can see that this badger's udders are clearly visible suggesting she has cub(s)

2) Soggy female badger and her cub.  I cant be sure this is the same female badger, but if so, this is one of her cubs with her.

3) ...and finally badger cub on its own:

Make use of poor quality inages
I had one night where many badgers stopped by for peanuts, but unfortunately I either had rain on the lens, or its was misty.  The resulting images were no use, but strung together into a time-lapse, gives an idea of what is going on.... Lots of badgers

Still used to create the following time-lapse

I'll sign off with a couple of new additions:


  1. So 8MP would be about 3264x2448 for a 4:3 format (

    From what little I've read about Camera Traps, the iR filter is controlled by some kind of solenoid. It slides across the lens for daylight images, and is pushed out of the way for night shots. My analogue cameras produce a weird purple cast image in daylight because the iR is not filtered out at all, day or night.

    Your true night image looks offset to the left and downwards compared to the one above. Did the camera move? Or maybe the filter is fixed and the camera moves a few mm within the box.

    I think the camera has a fixed resolution, but the processor can only process a limited amount of (video) data. So the raw image is down-sized from the camera and then a 640x480 stream is created/encoded.

    I think these camera trap/trail cams are brilliant, and the battery life is just amazing. You could have a lot of fun with a RaspberryPi trying to do the same thing, but how long would it run for on AA batteries?

  2. On closer inspection, those two camera images are taken ~2 weeks apart , so yes, I moved it ! I've been trying to get a closeup of one of the badgers however the IR tends to flood closeup, and it wont focus. I've tried masking off 1/2 the leds to see if that makes any difference.

    I've collected together all the parts I need to make a Pi-Trail cam, just need the time (and python practice) to put it together. I had planned on doing a wired one to begin with. Mine (proper) one has been running for ~2 months now on 1 set of batteries. I doubt I could build anything that could compete with that. The attraction of a 'build-your-own' approach is that it could theoretically trigger other networked cameras/IR illuminators.... so much to do, so little time ;)