# Timelapse with WVC54GCA (Linksys IP camera)


Video stream (no audio)

# vlc http://192.168.1.10/img/mjpeg.cgi
# vlc http://192.168.1.10/img/video.mjpeg
# vlc rtsp://192.168.1.10/img/video.sav

Video stream (audio)

# vlc http://192.168.1.10/img/video.asf

Snapshot

# wget --quiet --output-document=image.jpg 'http://192.168.1.10/img/mobile.cgi'
# wget --quiet --output-document=image.jpg 'http://192.168.1.10/img/snapshot.cgi?size=X&quality=Y'

- Size:
1 = 160×128
2 = 320×240
3 = 640×480

- Quality:
1 = Very high
2 = High
3 = Normal
4 = Low
5 = Very low

Timelapse

# cat timelapse.sh 
#!/bin/bash

action="$1"

if [ "$action" == "run" ]; then
 screen -dmS timelapse /bin/bash
"       screen -S timelapse -p 0 -X stuff "/root/timelapse/timelapse.sh take_pictures
 exit
fi

dir="/var/timelapse/jpg"

if [ "$action" == "take_pictures" ]; then
 camip="192.168.1.10"
 size="3"
 quality="1"
 url="http://$camip/img/snapshot.cgi?size=$size&quality=$quality"

 function getcol {
  echo $1 | awk -v c=$3 -F "$2" '{print $c}'
 }

 while `sleep 1`; do 
  date="`date +%u:%T`"
  second=`getcol "$date" ":" "4"`
  if [ "$second" == "00" ] || [ "$second" == "30" ]; then
   day=`getcol "$date" ":" "1"`
   hour=`getcol "$date" ":" "2"`
   minute=`getcol "$date" ":" "3"`
   od="$day-$hour$minute$second.jpg"
   wget --quiet --output-document=$dir/$od $url
  fi
 done
 exit
fi

if [ "$action" == "make_video" ]; then
 list="snapshots.list"
 vid="video.avi"
 if [ -f "$vid" ]; then
  timestamp=`date +%Y%m%d%H%M%S`
  vid="$vid-$timestamp"
 fi
 find $dir > $list
 mencoder "mf://$dir/*.jpg" -mf fps=7 -nosound -noskip -ovc copy -o $vid 
 rm $list
fi
# ./timelapse.sh run
# ./timelapse.sh make_video

Bonus

# cat cam.sh
#!/bin/bash

user="admin"
pass="1234"
ip="192.168.1.10"

action="$1"

if [ "$action" == "cat" ]; then
 file=`echo "$2" | sed -e 's/\./%2e/g' -e 's/\//%2f/g'`
 # http://www.gnucitizen.org/blog/hacking-linksys-ip-cameras-pt-3/
 curl --silent -u $user:$pass "http://$ip/adm/file.cgi?next_file=$file"
 exit
fi

if [ "$action" == "reboot" ]; then
 curl --silent -u $user:$pass "http://$ip/adm/reboot.cgi"
 exit
fi

if [ "$action" == "video" ]; then
 vlc "http://$ip/img/video.asf"
 exit
fi

No comments: