Hacking DropCam

Thanks to the wonderful world wide web and people who actually know what they are doing in the world of computer programming I have figured out how to make DropCam into a static image server for use as a regular webcam that takes static images and serves them at a specific interval.

The main reason for me doing this is because sometimes we have a weak signal at the mountain and the webcam at Nordic Valley goes offline:

DropCam Weak Signal Fix

Here is the live webcam using a the image I automate downloading and storing on Nordic Valley’s Web server: (this should update every 5 minutes)
Live Nordic Valley Webcam - Updated every 5 Minutes

Dropcam sells subscription plans for online video storage, and its all pretty easy to use and manage but also costs a pretty penny (An annual Subscription costs $99/year/per camera).

With this hack you could theoretically bypass paying for their CVR service and host it yourself (But trust me you will want to pay to have the features the subscription offers)

What this tutorial will allow you to do is programmatically grab the images that DropCam streams by periodically downloading the camera’s public thumbnail image they offer (Details on how to find this url below).

You would want to do this for a number of reasons.

For me the reasons were these:

  • I needed a static image url that would be reliable even if the camera went offline for a few seconds, minutes or hours that we could host on our own website to serve to skiutah.com for their webcam page.
  • I am not impressed by the lack of support from dropcam in not providing a flash alternative.
  • People who use iPhones iPads or don’t have flash installed will not be able to see a dropbox webcam with the embed code DropCam provides.
  • I can have control over my camera and back up photos automatically based on any kind of time scale I want without having to worry about how much CVR Storage is left on my account (An annual subscription still only allows for viewing of your footage 7 days back, so if you forget to record something like an event that happened or something you wish you would have captured, it is lost forever.)
  • I can do cool automatic daily timelapses that are always up to date.
  • I can create yearly timelapse images by programatically taking a photo at a certain time of day each day (of course I will have to put together the timelapse myself in something like FinalCut or something, but more on that later!)

My setup:

DropCam Pro
Hostmonster VPS Hosting

Steps:

  1. Find your static DropCam Image URL (looks something like this: https://nexusapi.dropcam.com/get_image?width=1280&uuid=6c9e661264b04c19a185fd8b851a528d )
  2. Write a Perl Script to programitically download the image to your server on a schedule to fit your needs.

1. To Find your static DropCam Image URL your camera must be publicly available.  Visit your “My Cameras” page ( https://www.dropcam.com/app/cameras ) and view this page’s source code (In google chrome on a mac hit Command Option U)

Once you are viewing the source code hit Command F to bring up the search bar and type “nexus”  Your public thumbnail url should be the 6th match like the image below: and will look like https://nexusapi.dropcam.com/get_image?uuid=6c9e661264b04c19a185fd8b851a528d\u0026width=280 (notice I’ve bolded the part that is important.

Screen shot of view source on dropcam to find static url

Copy that uuid and paste it into after this url schema: https://nexusapi.dropcam.com/get_image?width=1280&uuid= to test if your url works into a new browser tab and save the image to test:

Screenshot of how to save dropcam static image

Once you are able to get this image publically (notice I am using a private browsing window to test that I am not logged into dropcam and would be like any other Joe connected to the internet) you can now move on to step 2, the tricky part!

2. You can now schedule cron jobs to some perl scripts I have hacked together, or you can come up with your own.

If you just want to have this image automatically saved to your server every 5 minutes you can use this perl script on a cron job set to every 5 minutes like this:
(Note: if you are using hostmonster, here is the url to your cron job managment page: https://login.hostmonster.com/frontend/hostmonster/cron/index.html)
(Note: to find your perl directory you can log into console and type “which perl” and it will tell you, mine was /usr/bin/perl)

How to set up a cron job to a perl script in hostmonster to automate dropcam image downloads

Download this DropCam perl script example I have put together and unzip it. You will find a file called dropcam.pl or copy what I came up with below to make it easy and save this in a plain text file with the file extension .pl

Dropcam Hack via Perl Scripting

#!/usr/bin/perl
use LWP::Simple;

#Global Variables - Do not customize these
my $URLschema = 'https://nexusapi.dropcam.com/get_image?width=';
my $u = '&uuid=';

#=====================================================================================================================
#Custom Variables - You need to put the info you find from my tutorial (http://www.mastermindesigns.com/dropcam-hacks)
#=====================================================================================================================

#You can set a custom width here up to 1280 for dropcamp pro
my $width = '1280';
#Find your DropCam UUID and put it here
my $uuid = '6c9e661264b04c19a185fd8b851a528d';
#This is the path to the folder you want to save your image on your server
#Example below shows it in a folder called webcam_archive on the root of the primary domain
#Replace username with your hostmonster username or just figure out the correct path to the folder you want to save it in
my $path = '/home/username/public_html/webcam_archive/';
#This is where you put a filename you want to save the image as
my $filename = 'get_image.jpeg';


#The Concatenation of URL variables - Do not customize these
my $dropcamImageURL = join '',"$URLschema$width$u$uuid";
#The Save As Concatenation of variables - Do not customize these
my $saveAs = join '',"$path$filename";

#Function
getstore($dropcamImageURL, $saveAs);

How to set permissions in transmit to 755 so that the perl script can execute(Note: upload this to somewhere on your web server and set its permissions to 755 (VERY IMPORTANT – If you don’t do this the script won’t be able to run on the cron job.  You can do this using a ftp program like transmit, or you can also do it via your web console by CHMOD’ing it to 775 google that if you don’t know how to do this)
(Note: also make sure the perl LWP module is installed as it is not installed by default!)

Perl LWP Module Must Be Installed

 

Here is another script I hacked together that will download and save with the current day’s date hopefully after looking at my sample you will be able to just replace what you need with your own variables to suit your needs

#!/usr/bin/perl
use LWP::Simple;

my $dropcamImage = 'https://nexusapi.dropcam.com/get_image?width=1280&uuid=6c9e661264b04c19a185fd8b851a528d';
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $yyyymmdd = sprintf "%.4d-%.2d-%.2d", $year+1900, $mon+1, $mday;
my $path = '/home/username/public_html/webcam_archive/EveryDayArchive/';
my $extension = '.jpg';
my $saveAs = join '',"$path$yyyymmdd$extension";

getstore($dropcamImage, $saveAs);

This will save to the $path with the extension as a date like this YYYY-MM-DD.jpg

This was my first time ever scripting in perl and I think it is pretty straightforward. I am excited to learn more and see what else I can come up with:

To see this script in action where I am using it visit: http://www.nordicvalley.com/webcams/

Side Notes

Did you know you can remove the dropcam branding from your video? It is not a well known fact, and you can’t find it anywhere in the settings, but if you email support and kindly ask them to remove the branding along with your login info and camera id, they will remove the branding from your videos within a couple of hours! Just email support@nest.com with your login info and camera IDs asking for the branding to be removed!


6 responses

  • No, you have to keep it “public” else you receive a “forbidden”.

    James, how would you get the images if the site goes offline for a day? It seems like you are still grabbing the images from the internet using “hostmonster” which is another online server?

    Thank you

    • Thanks for confirming you have to have it public.

      It has been a while and it is still working on nordicvalley.com

      and yes, you will not be able to do this without a pretty good server… not sure you could get it to work with shared hosting… I’d be interested to see someone try.

      this is definitely not intended for anyone to try… you have to have some background in web development, and your own server capable of running perl etc etc.