#!/bin/bash set -e SOURCE="$1" TARGET="$2" if [ "$SOURCE" == "" ]; then echo "Source not defined. This is required." echo "Usage: $0 Source.movie Target.mp4" echo "eg \'$0 /path/to/source.(mkv|mpg|avi|...) /path/to/target.mp4\'" echo " " echo "Exiting." exit `/bin/false` fi if [ "$TARGET" == "" ]; then echo "Target not defined. This is required." echo "Usage: $0 Source.movie Target.mp4" echo "eg \'$0 /path/to/source.(mkv|mpg|avi|...) /path/to/target.mp4\'" echo " " echo "Exiting." exit `/bin/false` fi SUFF=`echo "$TARGET" | sed s/".*\."//g` if [ ! "$SUFF" == "mp4" ]; then echo "Target does not end in \".mp4\". This is required." echo " " echo "Exiting." exit `/bin/false` fi if [ -f "$TARGET" ]; then echo "$TARGET already exists. Not overwriting." echo " " echo "Exiting." exit `/bin/false` fi if [ ! -f "$SOURCE" ]; then echo "$SOURCE does not exist. This is required." echo " " echo "Exiting." exit `/bin/false` fi HandBrakeCLI -i "$SOURCE" \ -o "$TARGET" \ -Z "iPod Legacy" \ -X 480 -Y 320 \ -2 -T \ -b 500 -B 128 set +e exit