#!/bin/sh

help(){
    cat <<END
Usage: $0 [options] <filename>.[mov]
Options:
END
    exit 0
}

while getopts h name "$@"
do
    case $name in
*)
    help ;;
    esac
done
let shiftind=$OPTIND-1
shift $shiftind

if test "$#" != "1"
then
    help
fi
case $1 in
*.mov)
    input="$1"
    base=`echo $input | sed "s/\.mov$//"` ;;
*)
    help ;;
esac

echo Decimate $input to ${base}d.mov...

#!/bin/sh
ffmpeg -i $input -f s16le -y ${base}d.raw
sox -V -s -w -c2 -r48000 ${base}d.raw -r48000 ${base}d.wav
ffmpeg -i $input -vcodec copy -f mjpeg -y ${base}d.mjpeg
mencoder -fps 30000/1001 ${base}d.mjpeg -audiofile ${base}d.wav \
    -ovc copy -oac copy -ofps 30000/1001 -of lavf -o ${base}d.mov
