Code: Select all
#!/bin/bash
# burnevents -- burn a CD with ZoneMinder event files on it
#
# Written Fri Jun 24 10:30:05 EDT 2005 by jra@microsys.us
# extract the events for a day, by default "yesterday", find the event directories
# convert the JPEGs to a pair of MPEG's (which might be a bitch, since only certain
# frames get analyze counterparts), and rename to Name-Timestamp(-analyze).mpg
# zeroth, set magic variables
ZMHOME=/appl/zm1211
MPEGDIR=/appl/zm1211/mpeg
CDRDEV=/dev/hdc
FFMPEG=
ZMPASS=mumble
# first, calculate yesterday
# YESTERDAY=`date -d "-1 day" +%Y-%m-%d` # "normal": do yesterday
YESTERDAY=`date +%Y-%m-%d` # test: do today
STARTTIME="$YESTERDAY 00:00:00"
ENDTIME="$YESTERDAY 23:59:59"
# set -vx
cd $ZMHOME/events
mysql -u zm --password=$ZMPASS -D zm -B \
-e "SELECT MonitorId,Id,Name FROM Events \
WHERE StartTime > \"$STARTTIME\" and StartTime <= \"$ENDTIME\" \
ORDER BY MonitorID,Id" | sed 1d |
while read MONITOR EVENT NAME
do
pushd $MONITOR || continue # skip the line without getting confused
# if monitor directory not there
pushd $EVENT || (popd;continue) # same thing for the event directory
# Now, we're in the right place. Grab the timestamp off the first jpeg,
# then build the mpeg and name it appropriately
TIMESTAMP=`date -r \`ls | head -1\` -Iminutes`
echo ffmpeg -i %d-capture.jpg $MPEGDIR/$NAME-$TIMESTAMP.mpg
ffmpeg $FFMPEG -i %d-capture.jpg $MPEGDIR/$NAME-$TIMESTAMP.mpg
popd # event dir
popd # monitor dir
done
# now burn them
cd $MPEGDIR
# mkisofs -rJ * | cdrecord -immed $CDRDEV
# and remove them.
mv * archive/
So, first, any suggestions on $FFMPEG?
Once I get that done, I'll look into how hard doing a companion clip with the analysis frames will be; annoying, I suspect (involving making symlinks for all analyze frames that don't exist)...