#!/bin/sh # Process new images. rm -f /tmp/v1.jpeg cd /var/local/slugcam/new shopt -s nullglob for i in * do # Convert the uploaded single-frame MPEG to a JPEG image ffmpeg -i $i -sameq -deinterlace -vframes 1 /tmp/v%d.jpeg 2> /tmp/ffmpeg.out if grep -q 'invalid mb type' /tmp/ffmpeg.out then echo "$i bad (invalid mb type)" mv $i ../bad rm -f /tmp/v1.jpeg continue fi if [ ! -f /tmp/v1.jpeg ] then echo "$i bad (no file output)" mv $i ../bad continue fi # Add the timestamp timestamp=`basename $i .mpeg` mogrify -fill cyan -pointsize 30 -annotate 0,0,20,30 $timestamp /tmp/v1.jpeg # Save it in the jpegs directory mv /tmp/v1.jpeg ../jpegs/$timestamp.jpeg # Update the "latest" symlink ln -f -s $timestamp.jpeg ../jpegs/latest.jpeg # Remove the uploaded mpeg # rm $i mv $i ../new_bak done