#!/bin/sh
#
def_interlace=2
def_ratio=2
def_signal=1
def_tools=0
def_quality=2
def_sound=1

help(){
    cat <<END
Usage: $0 [options] <filename.[avi|dv|mov|mpg|qt]>
Options:
    -i n      n=0 progressive, n=1 top, n=2 bottom  ($def_interlace)
    -q n      quality, n=1 highest ... n=4 lowest   ($def_quality)
    -r n      aspect ratio, n=1 4:3, n=2 16:9       ($def_ratio)
    -s n      audio, n=0 mp2enc, n=1 toolame        ($def_sound)
    -t n      video, n=0 mjpegtools, n=1 ffmpeg     ($def_tools)
    -v n      norm, n=1 ntsc n=2 pal                ($def_signal)
    -h        Print this help message
END
    exit 0
}

interlace=$def_interlace
ratio=$def_ratio
signal=$def_signal
tools=$def_tools
quality=$def_quality
sound=$def_sound

while getopts i:q:r:s:t:v:h name "$@"
do
    case $name in
i)
    interlace=$OPTARG ;;
q)
    quality=$OPTARG ;;
r)
    ratio=$OPTARG ;;
s)
    sound=$OPTARG ;;
t)
    tools=$OPTARG ;;
v)
    signal=$OPTARG ;;
*)
    help ;;
    esac
done
let shiftind=$OPTIND-1
shift $shiftind

if test "$#" -lt "1"
then
    help
fi

for i in "$@"
do 
	echo cd $PWD \; nice $HOME/video/bin/encode-dvd \
		-i "$interlace" -q "$quality" -r "$ratio" \
		-s "$sound" -t "$tools" -v "$signal" $i; 
done | clustex pranika mobo pranika mobo
