#!/bin/bash

#Flash video converter. Convert *.flv file to avi.
#Copyright (C) 2006 DrRider
#Licensed under GPL. You can freely copy or modify this script.
#No warranty


usage() {
cat << eof

Flash Video converter. This script will convert *.flv video file to avi (mpeg4) or mpg (mpeg1) file types.

No input file or file type was not defined.
Usage: $0 [flvfile] [type]

Supported file type:
- avi (mpeg4)
- mpg (mpeg1)

Example: $0 filename.flv mpg

eof
}

#test if you have an input file

if [ -z $1 ] || [ ! -f $1 ]
then
	usage
	exit 1
fi

filename=`echo "$1" |sed -e 's/.flv//'`

#convert

case $2 in
	mpg)
		ffmpeg -i "$1" -y "$filename.mpg" >/dev/null 2>/dev/null
		echo "Converting finished."
	;;

	avi)
		ffmpeg -i "$1" -y "$filename.avi" >/dev/null 2>/dev/null
		echo "Converting finished."
	;;
	*)
		usage
		exit 1
	;;
esac
