Skip to content

Instantly share code, notes, and snippets.

@obfusk
Last active August 29, 2015 14:01
Show Gist options
  • Save obfusk/59dcc7136f92a30eedda to your computer and use it in GitHub Desktop.
Save obfusk/59dcc7136f92a30eedda to your computer and use it in GitHub Desktop.
dvd2pi
#!/bin/bash
set -e
chapter=1
dev=/dev/sr0
file=/media/media/felix/_dvd.mpg
host=beryllium
user=pi
usage () {
echo 'dvd2pi [-c CHAPTER] [-d DEVICE] [-f FILE] [-H HOST] [-u USER]' >&2
exit 1
}
while getopts :c:d:f:H:u: opt; do
case "$opt" in
c) chapter="$OPTARG" ;;
d) dev="$OPTARG" ;;
f) file="$OPTARG" ;;
H) host="$OPTARG" ;;
u) user="$OPTARG" ;;
:) echo "missing argument for: -$OPTARG" >&2; usage ;;
\?) echo "invalid option: -$OPTARG" >&2; usage ;;
esac
done
[ "$OPTIND" -gt "$#" ] || usage
cleanup () { ssh "$user@$host" "rm -i $file"; }
trap cleanup EXIT
mplayer --dvd-device="$dev" dvd://"$chapter" \
-dumpstream -dumpfile /dev/stdout \
| ssh "$user@$host" "cat > $file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment