Wednesday, July 9, 2014

Small Refinements

Over the last couple of weeks, I've been making some small tweaks to the time lapse system. I've noticed some shakiness in the final videos for one thing. Also, I wanted to do something to help reduce the heat buildup in the Pi over prolonged outdoor use, especially in a desert environment. Lastly, I wanted to fine tune the workflow of video creation.

Stability

There were 2 weak spots where I saw obvious room for improvement:
  1. The mounting bracket, which attaches the outer weather shell (e.g. food storage container) to the tripod
  2. The tripod base (legs)
The mounting bracket I was using until now was a simple piece of lightweight aluminum with a 90 degree bend in it. The problem was that it was rather springy whenever the wind blew. I decided to use some steel angle bracket I had on hand and bend into an "L" shape for a much more rigid mounting bracket.
Old bracket

New bracket
The next thing I wanted to address was the tripod base. I was using a lightweight point-and-shoot collapsible tripod with ball head, intended for point-and-shoot cameras. I was concerned that it might be causing some of the shaking and decided to use my heavier entry-level Manfroto tripod base, which can support a great deal of weight. The Pi is very light, but if it is unattended all day long, It will be safer. I decided to purchase an inexpensive ball head for this tripod, and went with the Oben BD-0.
The Oben BD-0 is cheap and small, but can support 6.6 lbs!

Temperature Control

A couple of times after bringing in the Pi after shooting for hours on hot days (temps into the low 90's), the Pi smelled kind of funny. I'm not sure, but it seems like the circuitry was getting baked. I considered installing a fan, but didn't want to draw extra power or introduce a separate power source. So to keep things simple, I went with a heat sink. This came in a 2-piece set for $7 on eBay. The Model A Pi only needs one. I have not done any measurements to know how effective this is, but it gives me piece of mind.
Aluminum heat sink on the Pi's 700 MHz ARM CPU

Workflow

I experimented using gstreamer to take advantage of the Pi's onboard video encoding. I got it to work (after building from source) -- and it is faster -- but the quality disappointed me. Maybe I haven't got the commands just right, but I decided to continue with mencoder. 

I realized that I was taking full resolution (5MP) still images at 2592×1944, which were then being reduced during video encoding to 1920x1080. So, I decided to go with 720p, and shoot at 1280x720 and encode the video to that same size. This saves space and time.

I also added the encoding to the shell script, after raspicam finishes taking the pictures, so an AVI will be automatically created. Further, I wrote a simple shell script to walk through the stills directory tree and delete jpegs and subfolders that are over a specified age.

I think the Pi is ready for the Colorado trip, so hopefully I will have some new time lapse videos to share of a cool place.

Video Conversion

Once I've transferred the avi from the Pi to my workstation (Mac Book Pro), I can convert it to a .mov using ffmpeg (free) like so:
ffmpeg -i "path/to/input.avi" -acodec libmp3lame -ab 192 "path/to/output.mov"

...or if I want to add music:
ffmpeg -i "path/to/input.avi" -i "path/to/music.mp3" -map 0 -map 1 -codec copy -shortest "path/to/output.mov"

It isn't necessary to convert to .mov because YouTube can understand the avi codec, but it makes the video playable on a mac, and allows the addition of music. It is also possible to use Audacity to trim and fade the music to fit the video length for a nice presentation.