Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
version of capture.sh that captures both audio and snapshots, requires sox, and imagemagick, ffmpeg
#! /bin/bash
# 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
# *****************************
# lots of garbage in here you can filter out *********
# ******************************
# 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`
fps=15
streamer -c /dev/video0 -o camLAST.jpeg # if you want to do some low pass or averaging
RAMP=0
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`
HOURNOW=`date +%H`
if [ $NOWDATE -gt $DDDATE ]
# if [ $HOURNOW -gt 14 ]
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.
#ctr=10000; for f in *.jpg; do let "ctr+=1"; mv $f cam${ctr:1}.jpg ; done
#done
ffmpeg -r $fps -sameq -i cam%04d.jpg ~/Videos/camTL-$DDDATE.mp4
#ffmpeg -r 15 -b 5000 -i webcam%04d.jpg ~/Movies/AUTOUPLOAD/`
/home/allasiabroadcaster/audiocombine.sh
echo "ffmpeg -sameq -i ~/Videos/camTL-$DDDATE.mp4 -i soundtrack.mp3 ~/Videos/camTL-$DDDATE-sndtrk.mp4"
ffmpeg -sameq -i ~/Videos/camTL-$DDDATE.mp4 -i soundtrack.mp3 ~/Videos/camTL-$DDDATE-sndtrk.mp4
# -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
if [ $HOURNOW -gt 09 ]
then
let "RAMP+=1"
let "RAMP%=$fps"
if [ $RAMP = 1 ]
then
rec -c 1 audio$DATETIME.wav trim 0 00:00:02.00
else
sleep 2
fi
streamer -c /dev/video0 -o temp1.jpeg
convert temp1.jpeg -resize 200% temp1.jpg
sleep 2
streamer -c /dev/video0 -o temp2.jpeg
convert temp2.jpeg -resize 200% temp2.jpg
sleep 2
streamer -c /dev/video0 -o temp3.jpeg
convert temp3.jpeg -resize 200% temp3.jpg
sleep 2
streamer -c /dev/video0 -o temp4.jpeg
convert temp4.jpeg -resize 200% temp4.jpg
sleep 2
streamer -c /dev/video0 -o temp5.jpeg
convert temp5.jpeg -resize 200% temp5.jpg
sleep 2
streamer -c /dev/video0 -o temp6.jpeg
convert temp6.jpeg -resize 200% temp6.jpg
convert temp*.jpg -average cam$DATETIME.jpg
##### streamer -c /dev/video0 -o cam$DATETIME.jpeg
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
echo yofool
# number of seconds between shots
sleep 2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment