What’s the best way to store the dash cam footage?

As I get ready to add a USB webcam to the Pi to use as a dash camera I have to ask: How should the dash camera recording be stored? The textbook definition of recording for a dash camera is to overwrite the oldest footage as storage space fills up. That way you get continuous recording while keeping the storage maxed out. In the Pi’s case, I’ve got ‘motion’ running continuously while a cron job deletes the oldest video in order to keep the SD card from filling up. The cron job removes video files based on last modified time. This is easy for a home security situation where the recording is constant so you can do the math to predict growth and determine hold far back in modified time from current time you need to delete files. But with a car, you might have a lot of video in a few days or none.

The next level in complexity for managing disk usage is to have a daemon running that continuously checks the amount of free disk space and appropriately removes the oldest files until the target amount of free space is reached. For example:

SD card = 16 GB
Free space after installing OS and needed software = 14 GB
Free space to maintain for OS and other tasks = 1 GB

That means we’re allowing ourselves 13 GB of space for videos. A daemon would check any time there’s less than 1 GB of free space and delete the oldest video file until that 1 GB is available.

Archiving dash camera footage permanently

The simple solution is to keep dash cam footage on the Pi. Ideally I’d like it if footage could be synced to the cloud service at www.blackboxpi.com for archival. The existing syncing daemon that syncs GPS data could also sync video files. But the daemon syncs data by grabbing local DB data via SQL and uploading it via a web API. For file upload and sync we’ll need something else. BTSync is great, but we can also use FTP or something more custom.  Is this feasible? Disk usage can grow outlandishly. Plus you’d have to take the Pi inside and plug it into a network cable (or use a USB wifi adapter to make it easier). Then the sync happens in the background.

For retrieval, users could enter their API key and gets a listing of video files to download. Archive can go back X days depending on available resources. Maybe a premium feature is to go back further?

This will only make sense if user syncs before the Pi fills up and starts overwriting old files. Otherwise you’re only getting what’s on the Pi at that moment. That might still be helpful if something happened that the user wants to store online.


There are a few different directions I can take the dash camera functionality next. I’ll start with keeping it on the Pi and consider upgrading to allow for syncing to the website for long term archival. How would you like dash camera footage stored? Do you want to keep it archived for long term storage? Or is it enough to keep it on the Pi for access as needed if anything happens during your drive?

Raspberry Pi 2 Dash Cam and Black Box

The day that the new Raspberry Pi 2 came out, I ordered one from the official distributor. It’s been in my server closet ever since, preparing it as a test platform for black box duty with added dash cam responsibilities. I’m still configuring and tweaking Motion so we can have a more stable dash camera platform. The Raspberry Pi Model B+ would occassionaly hang after running Motion for too long. With much beefier specs, I’m going to push this one a lot harder with higher frame rates and higher resolution.

For a related application as a home security server, I’ve experimented using the Pi w/ Motion and immediate live backup to another server. To do this I’m using BTSync. It’s not a stable version yet, but it works amazingly well. The problem is that the version available for the Pi tends to crash it sometimes. So it’s useless as a standalone dedicated system. With the Pi 2, I’m going to set that up again and see how it fairs running BTSync.