The purpose of this post is to combine two brilliant guides and save them (and the files) from disappearing…and to have them in one place in case I have to redo all this. So the first guide is by Christoph Buenger and can be found here. It describes step by step the basic installation process for motion (And Raspian, which I’ll left out here).
The second guide is by some unknown author I’ve found here and is based on a guide by Jeremy which can be found here. I didn’t use Jeremy’s guide because I had problems with motion in Arch Linux. This guide describes the google drive part. So after having installed Raspian and wi-fi we continue with motion:
sudo apt-get install motion
Since there have still been problems with motion and my RasPi Cam Module I had do continue with Christophs alternative Motion version by doing this:
sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev
tar zxvf motion-mmal.tar.gz
sudo mv motion /usr/bin/motion
sudo mv motion-mmalcam.conf /etc/motion.conf
With that done you have downloaded and unpacked the alternative version of motion and updated the already installed one with those new files (There will be an alternative download location for all files in this guide compilation at the end).
Now we make the motion deamon run always by running this:
sudo nano /etc/default/motion
and changing the config line to this:
The motion configuration file for this modified version can be found here:
sudo nano /etc/motion.conf
An config example will also be attached to the archive at the end if it’s not available from here.
According to this and the included file location, set the permissions like this:
sudo chmod 664 /etc/motion.conf
sudo chmod 755 /usr/bin/motion
sudo touch /tmp/motion.log
sudo chmod 775 /tmp/motion.log
One additional change to the motion.conf is required here to make the google drive version work.
The following line needs to look like that:
Of course you’ll have to create this location by doing this:
sudo mkdir /home/pi/monitor
chgrp motion /home/pi/monitor
chmod g+rwx /home/pi/moinitor
chmod -R g+rwx /home/pi/monitor
This may change since the Python script is currently not able to delete the .avi/.jpgs. Restart PI.
Now we install python by doing this:
sudo apt-get install pip
sudo pip install gdata
The necessary python scripts can be downloaded by doing this:
sudo wget http://files.mihevc.org/raspi/motion/uploader -O /etc/motion/uploader.py
sudo wget http://files.mihevc.org/raspi/motion/uploader.cfg -O /etc/motion/uploader.cfg
sudo chmod +x /etc/motion/uploader.py
Now edit the config file by adding your google data doing this:
sudo nano /etc/motion/uploader.cfg
Make sure the folder you’ve specified in the config exists on google drive.
Make sure you’ve recorded something by moving wildly in front of your cam. Look into /home/pi/monitor for .avis.
To test the python script run:
python ./uploader.py /etc/motion/uploader.cfg /home/pi/monitor/*.avi
If that worked out open your motion.conf and add this line to the end of the file
sudo nano /etc/motion.conf
on_movie_end python /etc/motion/uploader.py /etc/motion/uploader.cfg %f
At the moment the script won’t delete the jpg/avi files because of their rights. I’m working on that.
Ok got a workaround.
Insert in uploader.py after line 116 the following:
Thanks to the almighty Bazz!
All the required files can be found here: RaspiSurv Data (updated uploader.py with workaround above)
Edit: It seems you don’t need the special build of motion anymore: http://www.techrapid.co.uk/raspberry-pi/turn-raspberry-pi-nvr-motion/