Create a gist now

Instantly share code, notes, and snippets.

Timelapse movie maker from webcam for mac/linux
#! /bin/sh
# boranj!
# see instructions here:
# see also screencast version here:
# ************* 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`
# 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
DATETIME=`date +%Y%m%d%H%M%S`
NOWDATE=`date +%Y%m%d`
if [ $NOWDATE -gt $DDDATE ]
echo "day change"
for f in cam*.jpg; do
let "counter+=1"
mv $f cam${counter:1}.jpg
# 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
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`
DDDATE=`date +%Y%m%d
streamer -c /dev/video0 -o camLAST.jpeg
#let "counter+=1"
HOURNOW=`date +%H`
if [ $HOURNOW -gt 8 ]
#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
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?
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment