Last active
August 29, 2015 14:01
-
-
Save obfusk/59dcc7136f92a30eedda to your computer and use it in GitHub Desktop.
dvd2pi
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 | |
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