#!/bin/bash
#
# Requirements:
# Debian/Ubuntu aptitude install mencoder libmp3lame0 zenity
#
if [ $# -ne 2 ]; then
  echo "Usage: $0 inputfile outputfile"
  exit 65
fi
# This will convert mp4 videos into an avi format suitable for playing on the IAUDIO X5
COMMAND="mencoder $1 -o $2 -ovc lavc -oac mp3lame -lavcopts acodec=mp3:abitrate=96 -ofps 13 -vf scale=160:108"
$COMMAND 2>&1 &
COMMAND_PID=$!
zenity --progress --text="Converting Video $2" --auto-kill --pulsate &
PROGRESS_PID=$!
while [ -n "`ps -p ${COMMAND_PID} | grep ${COMMAND_PID}`" ] ; do
  sleep 1
done
kill $PROGRESS_PID
exit 0
