Created
February 27, 2011 10:05
-
-
Save c00kiemon5ter/846066 to your computer and use it in GitHub Desktop.
dvd2mpg
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
#!/usr/bin/env bash | |
title_clr="$(tput setaf ..)" # or setab | |
done_clr="$(tput setaf ..)" | |
madeby_clr="$(tput setaf ..)" | |
reset_clr="$(tput sgr0)" | |
shopt -s nocaseglob | |
set -e | |
echo -e "${title_clr}DVD to MPG Script$reset_clr" | |
ffmpegargs="-target pal-svcd" | |
format="mpg" | |
##########Option 3 has still to be finished#################################### | |
dumpdirectory="$HOME/dvdrip/rip" | |
outputdirectory="$HOME/dvdrip/out" | |
REQUIREMENTS="${REQUIREMENTS:-vobcopy ffmpeg}" | |
type -P $REQUIREMENTS &>/dev/null || { echo "Missing Something ?" >&2; exit 1; } | |
read -p "Rip DVD as one file or separate files (1,2)?" option | |
# Option must be a valid integer; numbers lower than 1 or greater than 3 are invalid ... | |
if [[ $option =~ ^[[:digit:]]+$ ]] && (( $option < 1 )) || (( $option > 3 )); then | |
echo -en "You didn't choose a valid option. Exiting! ${madeby_clr}Script By MystKid.$reset_clr" | |
exit | |
fi | |
echo "Creating folders" | |
rm -rf -- "$dumpdirectory" 2>/dev/null # empty the dump directory beforehand | |
[[ -d "$dumpdirectory" ]] || mkdir -vp "$dumpdirectory" | |
[[ -d "$outputdirectory" ]] || mkdir -vp "$outputdirectory" | |
echo "* Taking a VOB dump" | |
if (( $option == 1 )); then | |
vobargs="-l -o" | |
elif (( $option == 2 )); then | |
vobargs="-l -m -o" | |
elif (( $option == 3 )); then | |
vobargs="-l -M -o" | |
fi | |
vobcopy $vobargs "$dumpdirectory" | |
echo "* Re-encoding with FFmpeg" | |
dvdname="$(vobcopy -I 2>&1 | sed -n '/DVD-name/{s/^.*: //p}')" | |
part=1 | |
for vobinput in $(find $dumpdirectory -type f -iname "*.vob") | |
do | |
if (( $option == 2 )); then | |
mpgoutput="$outputdirectory/${dvdname}${part}.$format" | |
else | |
mpgoutput="$outputdirectory/${dvdname}.$format" | |
fi | |
ffmpeg -i "$vobinput" $ffmpegargs "$mpgoutput" | |
(( part++ )) | |
done | |
echo -e "${done_clr}Done!\n${madeby_clr}Script By MystKid.$reset_clr" | |
##################################By MystKid#################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment