My Time Lapse Bots have always relied on old computers, and while you can typically get old computers pretty cheap, they are also, well… old. They run old software, they often have hardware failures, non-working batteries, are heavy, and a lot of other things that are (sometimes) fine, but sometimes annoying.

Enter the Raspberry Pi, a small, inexpensive, low-power, modern Linux computer that can use an add-on camera module to create an all-in-one solution to time lapse captures. This is the kind of stuff I love playing with!

So here’s the story of making the CameraPi. I’ll avoid getting into code at this post and just talk about the process and some applications.

Once up and running, I added Avahi to give the Raspberry Pi a nice network name (camerapi.local) and I also installed Netatalk to allow my Mac OS X machines to easily connect to it. Neither of these are required for the camera stuff, but I tend to drop these on most Linux machines I use.

As for the image capture, while the camera utilities have some time lapse capabilities, they did not work for me, which is fine, I created my own. (I should note that the Raspberry Pi is for educational use, so I try to follow that idea and, well, learn a lot while using it.)

I wrote a simple bash script to capture a new image every 60 seconds. You can set whatever interval you like, but I like 60 seconds. For one day that gives you 1440 images, if you’re keeping track at home. Depending on your image size and compression settings that could be over 1GB per day of still images. I’m currently using 1280×720 for my image size, as that works well when compiling video.

As long as we’re capturing images every minute, why not have a way to display them remotely via a web browser? Sure! I also installed Apache for that. There are lighter HTTP servers, but I like Apache. I wrote a simple CGI script to grab the latest image file and display it on a page… and there’s also a link to all the images for the day. Oh, and the page auto-refreshes so it keeps showing the latest image. (The images are named like so: 20130905140427 using the YYYYMMDDHHMMSS format.)

OK, so we now have this running archive of photos. At some point (like, the second day) you’re going to have way more images in that folder than you want. Another shell script is the answer! Script #2 runs after midnight, grabs the date of the previous day, and moves all images matching that date to their own folder. (Oh, where do we store all these images? On a tiny USB thumb drive. It’s an 8GB drive. We figured filling that was better than filling the SD Card that contains the system.)

Now we’ve got a folder named 20130905 with 1440 images in it. We should probably do something with it… Make a video! Once the files are moved we run a command with mencoder to compile all the JPG files (sorted by name, which is also sorted by date) into an AVI file. I don’t really care for AVI files though, so when that is done (and, it takes about 6 hours due to the high-quality encoding settings I use) we then use avconv (which used to be ffmpeg, sort of, oh, Linux!) to convert the AVI to an MP4 file. That does not take hours. This is all messy and could be done better.

So after all that, we now have an MP4 file we can view in our browser, though it’s a silly MP4 that needs to completely load before it starts. Silly! There must be a better way.

Yes. There must be a better way. I’m sure there is. Here’s the thing. I really just started hacking. I didn’t know where I was going, so it’s all been guessing and trying things along the way. That’s the beauty of it. I’m not building this for a client. I’m not building a commercial product. I’m just playing and learning. I love it.

Oh, I forgot, I also set my capture script to launch at startup as a service. That means it also stops cleanly when you halt the system. Also, you can halt the system via another CGI just by loading a web page. Secure? Probably not. Ideally I’d like to be able to have the Pi create a WiFi network I can attach to from my phone and control. That would be nice. I’m sure it’s doable, I just need to dig in more. Dig. In. More.

Well that was fun! Thanks for reading this. If anyone really wants more info on the code, I could clean it up a bit (or not) and post it. As always, improvements are very welcome.

2013.05.18

This is the method I use for creating 1280×720 (aka, 720p) time lapse video files from a GoPro camera using MPEG Streamclip.

I use the time lapse setting on the GoPro, which creates images that are 2592 pixels wide by 1944 pixels high, though we care less about the pixel width and height, and more about the aspect ratio, which is all wrong for a proper video. (In fact, you can use this method for any still images you wish to finish as a video file.)

I start by compiling all the stills into a video file, and I use QuickTime Player 7 for that. There are other tools, but that’s what I’m currently using, and no the most recent version of QuickTime Player is hobbled crap that won’t work. (Hey Apple, how about fixing that?)

To choose the best crop I usually do a screen grab of the image area, and then open that in Photoshop (or whatever) and size it to 1280 wide. The height should be about 960 (depending on how accurate your screen shot is.) Time for Math! 960 – 720 = 240, so we need to crop 240 pixels from the height. You can easily just skip this step and plug 120 into the top and bottom crop, but this step will let you easily make some other decision, like 140 and 100. As long as your top and bottom crop add up to 240, you’re good.

Sometimes I like to make a marquee that’s 1280 x 720 to get a better idea of the crop… Feel free to skip this step if you don’t need the precision I require in every single thing I do.

OK! Here’s the export window in MPEG Streamclip, where you can see I’ve set the size of the video to “Other” and plugged in the 1280 x 960 values. I then put the 140 and 100 values in the top and bottom crop boxes, respectively. All the other settings are what I typically use for MPEG Streamclip. (The one thing I tend to change which isn’t show here is the ‘Limit Data Rate’ value. But that’s a post for another time. Oh, I didn’t do it here, but you can disable the audio track as well.)

Here’s our final video output at 1280 pixels wide by 720 pixels high. Now, since we started with a video that was 2592 pixels wide by 1944 pixels high, we could actually get all fancy and just select a portion of the video to output at the final resolution. This involved a lot more math, but it’s a possibility, so I’ll leave it up to you to explore.

2013.03.09

Every now and then I see a post that talks about photography, and how many factors go into the cost of hiring a “real” photographer (and by “real” I mean “professional”) so for my own reference in the future, I wanted to write up my thoughts on the topic of shooting video. (For our purposes today, assume you’ll be shooting a few talking-head videos for a presentation.)

I’m calling this “A Guide to Video for Smart People” because someone very intelligent, who I greatly respect, hired me to do a video shoot. Since, we had to talk about pricing, I figured I’d share some of my thoughts.

1. When you hire a professional, you get a professional.
What is a professional, exactly? It’s someone who uses pro-gear, and has the knowledge to use it. Someone who has experience, and has done professional shooting before. Someone who knows about shooting, and lighting, and pacing, and talking to talent, and audio, and composition, and dozens of other things you don’t even think about because it’s second nature after a while.

2. Professionals use professional gear.
Everyone’s got a camera nowadays, but there’s more to shooting than a camera. For a typical interview shoot you might have a camera, lens, lights, audio recorder, microphone, studio headphones, tripod, stands, spare batteries, spare cards, spare XLR cables, reflectors, and a dozen other things you bring on every shoot. I’m not suggesting you need top-of-the-line everything, but even on the low-end it can be $2,000 for a basic set-up.

3. Professionals are thinking.
If you haven’t had the luxury of scouting locations, you might show up and get a quick tour of the location so you can pick a spot to shoot in. When I walk into a room, I’m looking at the layout, the lighting, determining where all the outlets are, looking at the height of the ceiling, figuring out where the tables and chairs can go, etc. If there are windows in the room, is it cloudy outside? How will the changing sunlight affect the lighting during the shoot? And that’s all before setting up the tripod.

4. Professionals respect your work.
Besides taking the shoot seriously and doing a great job capturing the footage, a pro-shooter will make sure your work is preserved. Anyone with clients will know that even though you might provide them with files, there’s a chance they’ll come back a year later (or five years later!) and ask for it again. For a recent shoot the raw footage came out to be about 9GB of data. After editing it was about 30GB of data. That all gets backed up, and archived, and managed so that you can go back a year later and provide the footage again.

5. Professionals edit.
Even if the client thinks it’ll be quick and easy and there won’t be any editing… there’s always editing. Unless you’re just doing camera ops for someone else and they want the raw footage, you’re editing. So much DSLR shooting is done today with secondary audio that at a minimum there’s the syncing of audio with the video. Add bump-in and bump-out, a few cross-fades, choosing the best take, and render time, and you’ve got some time invested. (I’m not even getting into the copying, burning, and delivering of the work, but hey, that’s another aspect.)

OK, that’s part one of my “Guide to Video for Smart People”. We covered five points. There are more, but I wanted to keep this brief. The great thing about working with smart people is that they’re smart (duh!) so educating them to some of these facts shouldn’t be too hard to do. Chance are after the first shoot you do, they’ll get it, and it’ll be the start of a great (working) relationship. :)