Skip to content

Instantly share code, notes, and snippets.

@nfelger
Created January 26, 2013 19:45
Show Gist options
  • Save nfelger/4644122 to your computer and use it in GitHub Desktop.
Save nfelger/4644122 to your computer and use it in GitHub Desktop.
Script to make a movie from some 480x640 pixel JPGs, and imprint the images with their creation date (OSX only).
#!/bin/bash
# Image sequence counter. Makes the ffmpeg command simpler.
imgNr=0
# Clear any previously generated intermediate files.
rm -rf dated rotated
mkdir dated
mkdir rotated
# Expecting images named IMG_*.JPG.
for file in IMG_*; do
echo $file
(( imgNr++ ))
# Get file creation date (some OSX magic).
dateStr=`/usr/bin/mdls -r -name kMDItemFSCreationDate $file | sed 's/ .*//'`
imgDate=`date -j -f '%Y-%m-%d' $dateStr +'%b %d %Y'`
# Rotate image if necessary.
if [[ `identify $file | grep 640x480` ]]; then
convert -rotate 90 $file rotated/$file
file=rotated/$file
fi
# Imprint the date.
convert $file \
-pointsize 30 \
-font '/Library/Fonts/KozMinPro-Regular.otf' \
-stroke '#1B1BB3' \
-fill '#1B1BB3' \
-gravity NorthEast \
-annotate +15+15 "$imgDate" dated/`printf "%05d" $imgNr`.jpeg
done
# Video time! (-framerate is the input framerate, -r is the output framerate)
rate=10
ffmpeg -framerate $rate -f image2 -i dated/%05d.jpeg -r $rate -vcodec libx264 out.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment