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:
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)
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!)
Hostmonster VPS Hosting
- Find your static DropCam Image URL (looks something like this: https://nexusapi.dropcam.com/get_image?width=1280&uuid=6c9e661264b04c19a185fd8b851a528d )
- 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.
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:
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)
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
#!/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);
(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!)
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/
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 email@example.com with your login info and camera IDs asking for the branding to be removed!