#!/bin/bash

if [ -z "$1" ]; then
	echo "usage: ${0##*/} DIRECTORY..." >&2
	exit 1
fi

for i in $*; do
	if [ ! -d "$1" ]; then
		echo "$i: not a directory" >&2
		continue
	fi

	echo "processing $i..."
	i="${i%/}"
	ls "$i"/*.jpg | jpeg2yuv -Ip -L0 -R0 -f24 2>/dev/null | theora_encode -v 8 -o "cap.$i.ogg" -
done
