Skip to content

Instantly share code, notes, and snippets.

@ab
Created December 15, 2015 11:17
Show Gist options
  • Save ab/ac6f4205e04ff5d1aead to your computer and use it in GitHub Desktop.
Save ab/ac6f4205e04ff5d1aead to your computer and use it in GitHub Desktop.
Glue scripts for cutting together time lapse video
#!/bin/bash
set -eu
if [ $# -ne 3 ]; then
cat >&2 <<EOM
usage: $(basename "$0") YEAR MONTH {high|low|concat-only}
EOM
exit 1
fi
year="$1"
month="$2"
resolution="$3"
run() {
echo >&2 "+ $*"
"$@"
}
run_concat() {
run ffmpeg-concat "$year-${month}.cat.mp4" "$year/daily/$year-$month"-*.mp4
}
# oneoff for 2012-07-16, where we upsample to 1440x1080
# ffmpeg -f image2 -framerate 15 -pattern_type glob -i '*.jpg' -r 30 -s:v 1440x1080 -vf "drawtext=fontfile=/usr/share/fonts/truetype/roboto/Roboto-Regular.ttf: text='2012-07-16': [email protected]: fontsize=24: x=(w-text_w-8): y=8: borderw=1" -vcodec libx264 out.mp4
export QUIET=1
mkdir -p "$year/daily"
case "$resolution" in
high)
export OUTPUT_RESOLUTION=1440x1080
for day in $(ls "$year/$month"); do
WATERMARK=$year-$month-$day run ffmpeg-timelapse \
"$year/$month/$day/*.jpg" \
"$year/daily/$year-$month-${day}.mp4"
done
;;
low)
for day in {01..31}; do
if [ -z "$(shopt -s nullglob; echo "$year/$month/$year-$month-${day}"_*.jpg)" ]; then
echo "No files for $year-$month-$day"
continue
fi
WATERMARK=$year-$month-$day run ffmpeg-timelapse \
"$year/$month/$year-$month-${day}_*.jpg" \
"$year/daily/$year-$month-${day}.mp4"
done
;;
concat-only)
run_concat
exit
;;
*)
echo >&2 "should be high/low, not $resolution"
exit 2
;;
esac
run_concat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment