Skip to content

Instantly share code, notes, and snippets.

@danpaluska
Created July 14, 2010 17:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danpaluska/475719 to your computer and use it in GitHub Desktop.
Save danpaluska/475719 to your computer and use it in GitHub Desktop.
Timelapse movie maker from webcam for mac/linux
#! /bin/sh
# boranj!
# see instructions here:
# http://broadcasterproject.wordpress.com/2010/07/14/how-to-make-a-timelapse-shared-memory-server/
# see also screencast version here: http://plebiandesign.com/blog/?p=552
# ************* for capturing frames from a camera:
# ************* LINUX is STREAMER
# ************* MAC is WACAW
# whatever you want to be your directory of files
cd ~/Pictures/OMPD
# make a subdirectory with today's date, then go to it.
mkdir `date +%Y-%m-%d`
cd `date +%Y-%m-%d`
streamer -c /dev/video0 -o camLAST.jpeg # if you want to do some low pass or averaging
DDDATE=`date +%Y%m%d`
DATETIME=`date +%Y%m%d%H%M%S`
counter=10000
# at 15 seconds per shot, 4/min, 240/hr, 10 hours = 2400 shots
# while [ $counter -ne 3400 ] # run a fixed number of shots.
#while [ `date +%H` -lt 23 ] # if it's less that 11pm
while [ 1 ] # run all the time
do
DATETIME=`date +%Y%m%d%H%M%S`
NOWDATE=`date +%Y%m%d`
if [ $NOWDATE -gt $DDDATE ]
then
echo "day change"
counter=10000
for f in cam*.jpg; do
let "counter+=1"
mv $f cam${counter:1}.jpg
done
# convert *.jpg ~/Movies/AUTOUPLOAD/OMPD-$DDDATE-$DATETIME.mp4
# this is a one liner you can run if you need to manually do a day that got missed.
# for f in *.jpg; do let "counter+=1"; mv $f screen${counter:1}.jpg ; done
#done
ffmpeg -r 15 -sameq -i cam%04d.jpg ~/Videos/camTL-$DDDATE.mp4
#ffmpeg -r 15 -b 5000 -i webcam%04d.jpg ~/Movies/AUTOUPLOAD/`
# -b 5000 to limit movie size.
cd ~/Pictures/OMPD
mkdir `date +%Y-%m-%d`
cd `date +%Y-%m-%d`
counter=10000
DDDATE=`date +%Y%m%d
streamer -c /dev/video0 -o camLAST.jpeg
fi
#let "counter+=1"
echo $DATETIME
HOURNOW=`date +%H`
if [ $HOURNOW -gt 8 ]
then
#scrot screen$DATETIME.jpg
streamer -c /dev/video0 -o cam$DATETIME.jpeg
#streamer -c /dev/video0 -o cam$DATETIME.jpeg
#wacaw --jpeg -n 4 webcam${counter:1}.jpg
echo "captured cameras"
#composite -blend 20 camNEW.jpeg camLAST.jpeg camMiddle.jpg
#mv camMiddle.jpg cam$DATETIME.jpg
#rm camLAST.jpg
convert cam$DATETIME.jpeg -resize 200% cam$DATETIME.jpg
#cp camMiddle.jpg camLAST.jpg
fi
rm *.jpeg
#wacaw --jpeg -n 4 webcam${counter:1}.jpg
# resize images using imagemagick here?
echo yofool
# number of seconds between shots
sleep 20
# make a beep here? display a shot onscreen?
done
# one shot/15sec, played at 10 fps = 150x speedup. 150min(2.5hr) = 1 min vid. 10hrs = 4min
# about mac cron jobs on laptops and sleep times
# http://www.thexlab.com/faqs/maintscri...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment