Time Lapse setup using D-Link DCS-931L and DCS-932L, mencoder, crontab and basic scripting
- setup cameras to ftp pictures taken every minute to servers
- write scripts to mk timerelease images and pages
- test scripts to mk timerelease images and pages
- manually execute for a few times
- create crontab entry to run scripts
- -> crontab -e
add line for 11:58 every day to execute mk all avi script
crontab: installing new crontab
------------------------------------------------
--> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.EZv91Z installed on Sun May 10 22:07:58 2015)
# (Cronie version 4.2)
# MIN HOUR DAY MONTH DAYOFWEEK COMMAND
58 23 * * * /home/some-user/bin/mkallavi
# 5 6-20 * * * /home/some-user/bin/get-map # every 5 minutes between 6 am and 8 pm
# */2 7-10 * * * /home/some-user/bin/get-map # every 2 minutes between 7 and 10 am
# */2 14-18 * * * /home/some-user/bin/get-map # every two minutes between 2 and 6 pm
------------------------------------------------
- visit pages and enjoy: time lapse #1
- visit pages and enjoy: time lapse #2
SCRIPTS
time lapse
#!/bin/bash
# john meister 14nov2013 # updating mkavi to mkallavi to include two directories 9 may 2015
# DIRNAME=`pwd | awk -F / '{print $4}'` ##### /var/www/thisdomain/public_html/Time_Lapse/2015_04_07 (7th field)
############################################################################################################################################
# added for cron - tested 10 may 2015 # DATED=`date '+%Y%m%d'` # cd /var/www/thisdomain/public_html/john/web/jm/Time_Lapse/$DATED
# NOTE: if ssh doesn't work, set perms on directory .ssh to 700, and authorized_keys to 600
############################################################################################################################################
DATED=`date '+%Y%m%d'`
cd /www/thisdomain/public_html/Time_Lapse/$DATED
DIRNAME=`pwd | awk -F / '{print $7}'` # note this directory
chmod 644 *.jpg
find . -type f -size 0 -exec rm {} \;
ls *.jpg > $DIRNAME.files.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4 -o $DIRNAME.avi -mf type=jpeg:fps="24" mf://@$DIRNAME.files.txt
/home/john/bin/mkpg "Time Lapse $DIRNAME"
echo "< a href="$DIRNAME/$DIRNAME.avi" target="new">$DIRNAME.avi< /a> < br>" | tee -a ../Daily_Time_Lapse_2015.html
#######################################################################################################
mkdir /var/www/Driveway/$DIRNAME
scp -rp remote_account@silver-edge.dreamland.com:/home/remote_account/johnmeister.com/jeep/sj/driveway/$DIRNAME /var/www/Driveway/
cd /var/www/Driveway/$DIRNAME
chmod 644 *.jpg
find . -type f -size 0 -exec rm {} \;
ls *.jpg > $DIRNAME.files.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4 -o $DIRNAME.avi -mf type=jpeg:fps="24" mf://@$DIRNAME.files.txt
/home/john/bin/mkpg "Time Lapse $DIRNAME"
echo "<a href="$DIRNAME/$DIRNAME.avi" target="new">$DIRNAME.avi</a> < br>" | tee -a ../Daily_Time_Lapse_2015.html
scp *.avi ALL.html README.html remote_account@silver-edge.dreamhost.com:/home/remote_account/johnmeister.com/jeep/sj/driveway/$DIRNAME
scp ../Daily_Time_Lapse_2015.html remote_account@silver-edge.dreamhost.com:/home/remote_account/johnmeister.com/jeep/sj/driveway/
cd
#######################################################################################################
make page
#!/bin/bash
# 28 oct 2013 - john http://johnmeister.com - updated 8 may 2015
#################################################################
# mkpg - creates a page to display all images in a directory
#################################################################
CAT=/usr/bin/cat
CP=/usr/bin/cp
DATE=`date | cut -c 5-11` ; export DATE # echo $DATE
FDATE=`/bin/date +%d%b%y-%H%M` ; export FDATE # echo $FDATE
GREP=/usr/bin/grep
LS=/usr/bin/ls
MKDIR=/usr/bin/mkdir
MV=/usr/bin/mv
PERL=/usr/bin/perl
SORT=/usr/bin/sort
TITLE="`echo "$1"`" ; export TITLE ; echo $TITLE
UNIQU="/usr/bin/uniq -u"
VI=/usr/bin/vi
WCL="/usr/bin/wc -l"
##############################################
# create backup copies of ALL, Header, Readme and footer files
##############################################
$MKDIR z 2>/dev/null
$MV ALL.html z/ALL.html-`/bin/date +%Y-%m-%d-%Hh%Mm` 2>/dev/null
$MV README.html z/README-`/bin/date +%Y-%m-%d-%Hh%Mm` 2>/dev/null
$MV HEADER.html z/HEADER-`/bin/date +%Y-%m-%d-%Hh%Mm` 2>/dev/null
$MV FOOTER.html z/FOOTER-`/bin/date +%Y-%m-%d-%Hh%Mm` 2>/dev/null
##############################################
$CP /var/www/thisdomain/public_html/README.html README.html
$CP /var/www/thisdomain/public_html/HEADER.html HEADER.html
$LS z
##############################################
# create new ALL.html file - TOP
##############################################
echo "< html>< head>< title>$TITLE - john meister © 2015< /title>" > ALL.html
$CAT /home/john/bin/BASE/A >> ALL.html
##############################################
# create < h1> tag for page - take from mkpg cmd
##############################################
echo "" >> ALL.html
echo "< center>< h1> $TITLE < /h1>" >> ALL.html
##############################################
# image tags and place D600, D7100, canon files
##############################################
$LS *.jpg > IMGs 2>/dev/null
$LS *.JPG >> IMGs 2>/dev/null
$CAT IMGs | $GREP JM6 > IMG.html 2>/dev/null
$CAT IMGs | $GREP JM7 >> IMG.html 2>/dev/null
$CAT IMGs | $GREP D7K >> IMG.html 2>/dev/null
$CAT IMGs | $GREP JEM >> IMG.html 2>/dev/null
$CAT IMGs | $GREP IMG >> IMG.html 2>/dev/null
$LS *.jpg *.JPG | $GREP -v JM6 | $GREP -v JM7 | $GREP -v JEM | $GREP -v IMG >> IMG.html 2>/dev/null
$PERL -pi -e 's/(.*)/ < img src="$1"> < BR>$1 < HR>/g' IMG.html 2>/dev/null
$PERL -pi -e 's/ < img src=""> < BR> < HR>//g' IMG.html 2>/dev/null
##############################################
$CAT IMG.html >> ALL.html
##############################################
# close out content section, add Footer
##############################################
echo "< /center>" >> ALL.html
$CAT /home/john/bin/BASE/B >> ALL.html
echo " the numbers on the left should match: "
$MV IMGs z ; $WCL z/IMGs
$MV IMG.html z ; $WCL z/IMG.html
echo " end of ALL.html creation, backup files in z "
##############################################
|