Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created July 23, 2018 12:26
Show Gist options
  • Save Unitech/884423b957247e7cd60257009e0fcf3a to your computer and use it in GitHub Desktop.
Save Unitech/884423b957247e7cd60257009e0fcf3a to your computer and use it in GitHub Desktop.
Timelapse with time written on it, logitech c920 + fswebcam on Ubuntu 18
#!/bin/bash
# Timelapse controller for USB webcam on Ubuntu 18.04 / works well with logitech C920
# Before using it run:
# sudo apt install fswebcam imagemagick
DIR=frames
#counter for filename
n=1
#counter for files saved
x=1
#number of screenshots to take
num=1000000
#interval at which screenshots get taken in seconds
interval=60
while [ $x -le $num ]; do
filename=$(printf "%s.jpg" `date '+%Y-%m-%d-%H:%M:%S'`)
let n=n+1
#Capture image
fswebcam -S 10 -D 4 -r 1280x720 --jpeg 95 --no-banner --save $DIR/$filename
#add timestamp with imagemagick
convert $DIR/$filename -pointsize 30 -font '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf' -fill white -stroke black -gravity s\
outheast -annotate +4+0 "$(date +"%D %r")" $DIR/$filename
x=$(( $x + 1 ))
sleep $interval;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment