Created
April 1, 2012 14:17
-
-
Save halfninja/2275548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Encode a file to an MP4 that my TV can play. | |
## Assumes SD card is inserted at /media/NO_NAME, | |
## and Handbrake CLI is installed (apt-get install handbrake-cli). | |
## See "HandBrakeCLI -z" for list of presets. | |
SDCARD=/media/NO_NAME | |
HANDBRAKE_PRESET=Normal | |
function die() { | |
echo "$@" 1>&2 | |
exit 1 | |
} | |
function usage() { | |
die "Usage: encode_for_tv FILENAME" | |
} | |
if [[ ! -d "$SDCARD" ]]; then | |
die "Target '$SDCARD' not found." | |
fi | |
FILE=$1 | |
if [[ "$FILE" == "" ]]; then | |
usage | |
elif [[ ! -f "$FILE" ]]; then | |
die "File '$FILE' does not exist." | |
fi | |
DEST=$SDCARD/`basename "${FILE%.*?}.mp4"` | |
if [[ -f "$DEST" ]]; then | |
die "Destination '$DEST' already exists, not overwriting." | |
fi | |
echo "Encoding file $FILE..." | |
echo "Encoding to $DEST..." | |
HandBrakeCLI -i "$FILE" -o "$DEST" --preset=$HANDBRAKE_PRESET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment