Send yourself an email of an avi of events every 24 hrs.

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
spagnuts
Posts: 1
Joined: Wed Jun 30, 2010 7:35 am
Location: Auckland, New Zealand

Send yourself an email of an avi of events every 24 hrs.

Post by spagnuts »

I wrote this so i could get an email with the last 24hrs of events in one avi file, i suck at code but this works for me and thought it maybe useful to others.

Code: Select all

#!/bin/bash

#Get last 24hrs of jpgs from zm events
find /var/www/html/zm/events/1/ *.jpg -ctime -1 -exec cp --parent {} /some/temp/folder \;

#Take the event id and append it to the file name
for directory in `ls /some/temp/folder/var/www/html/zm/events/1`
   do for each in `ls /some/temp/folder/var/www/html/zm/events/1/$directory`
       do mv -v /some/temp/folder/var/www/html/zm/events/1/$directory/$each /some/temp/folder/zm-event/$directory-$each
   done
done

#Delete unwanted analsed jpg files
rm -rfv /some/temp/folder/zm-event/*analyse.jpg

#change directory
cd /some/temp/folder/zm-event

#Encode into an avi
mencoder "mf://*.jpg" -mf fps=15 -o last24hrs.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=400

#Remove jpgs from zm-event directory
rm -rf /some/temp/folder/zm-event/*.jpg

#Email avi to email address
nail -v -s "Zone Minder" -a /some/temp/folder/zm-event/last24hrs.avi your.email@address.com < /dev/null
this only takes the jpgs from camera 1 but the top part of the script can be copied and the camera numbers changed. I have this working with 3 cameras.

Ok the /some/temp/folder needs to be made and the /some/temp/folder/zm-event

mplayer needs to be installed, to get mencoder.

nail needs to be install and /etc/nail.rc needs to be edited and add the line
set smtp=smtp.your-isp.mail.box

then i crontab'd it to run every 24hrs
as root
crontab -e
add the line
00 4 * * * /location/of/bash-script.sh
runs it at 4am

That should do it.
Hope this is useful, and not already done :)
Post Reply