Thursday 22 March 2018

BirdBox 2018: time-lapse video

For 2018 I thought I'd try to gather periodic snapshots from my Maple tree bird box.


The idea is to make a series of time-lapse videos.


I'm hoping to capture nest building and maybe show the chicks growing from tiny naked blobs to fully feathered birds.

how's it done?


Whenever my battery powered Raspberry Pi system is triggered by activity, the system powers-up, the Linux program 'motion' starts, and short video clips are captured when motion detects a sufficient change in pixel value from one frame to another.

All that is needed to get motion to also collect periodic snapshots, is to edit the motion.conf file.

Its difficult to know how many pictures I should be taking, but 2 per minute would give 120/hr or 1200 in 10 hours. Turning this into a video with a frame rate of 10fps would give a 2 minute video for 10 hours of pictures. Likewise I could use 25fps with images recorded over 25 hours, which would play in 2 minutes. So I hope that taking a picture every 30s of run-time is about right.

Also note that my system only runs when triggered by activity (i.e. it runs for 10 minutes beyond the last time it was triggered) so during the nest building phase, the system will not run for as many hours per day as it will later in the season, when the chicks are being fed.

Image size varies with content, but each image is typically about 25kB, so that should not create a storage problem as long as I remember to copy the files off the system every few weeks.

mods to motion.conf


I'm using the 'snap-shot' feature of motion, so I just need to set an interval, a file name format and a file location.

# Snapshots (Traditional Periodic Webcam File Output)
############################################################

# Make automated snapshot every N seconds (default: 0 = disabled)
snapshot_interval 30

# Target base directory for pictures and films
target_dir /home/pi/mVideo

# File path for snapshots (jpeg or ppm) relative to target_dir
snapshot_filename timelapse/%Y%m%d%H%M%S

So my time-lapse photos will be saved in: /home/pi/mVideo/timelapse  with a unique, time-stamped file name.


creating a time-lapse video


There must be loads of ways to do this on Linux, but I'm going to use two terminal commands. After downloading the required image files, I copy them into a new empty directory on my laptop, then hit F4 to open a terminal at this location.

Then I rename the images to give them sequential numbers from 1 to (possibly) 9999 using the rename command:-

rename 's/.+/our $i; sprintf("elapse-%04d.jpg", 1+$i++)/e' *

Note: %04d sets the number of digits.

Then use ffmpeg to convert the jpegs to mp4:-

ffmpeg -framerate 10 -i elapse-%04d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p TimeLapse.mp4

This seems to work fine, but due to a current lack of constructive activity inside the box, I don't have any interesting videos to post at the moment.

the odd couple


A pair of blue tits visit most days, just to claim this box for themselves. And the female has made a good job of clearing out the odd bits of rubbish that I missed when the box was taken down last summer. This couple are quite easy to tell apart, which is not often the case with blue tits.

our blue tit pair: male on the left, female on the right

It looks like the male needs a hair cut (and those head feathers look quite coarse), while the female has a much tidier blue cap.



No comments:

Post a Comment