You are not logged in.
hello guys i wrote my first bash script. waht it basically does is converts DVD's into any format you want with ffmpeg.
it is ment to be run as user and not as root. all you got to do is edit the first lines as you wish, insert a dvd and run the script.
its a very simple script but i want to share it as somone might find it useful.
So this is what it does:
-uses vobcopy to save the vob files in your home directory
-encodes them to any format you specify
-deletes the *.VOB files after the encode is done so you dont waste disk space
#!/bin/bash
#####Needed packages: vobcopy,ffmpeg,libdvdread,libdvdcss,libdvdread2-dev#####
##########Scripy By Mystkid (nicolast88@gmail.com)############################
##############################################################################
dump="$HOME/dvdrip/vob" ##default:"$HOME/dvdrip/vob"
output="$HOME/dvdrip/out" ##default:"$HOME/dvdrip/out" output folder
vobargs="-l -x -o" ##default:"-l -x -o" vobcopy options
ffmpegargs="-target pal-svcd" ##default:"-target pal-svcd" ffmpeg options
format=".mpg" ##default:".mpg" output format
REQUIREMENTS=${REQUIREMENTS:-"vobcopy ffmpeg"}
##############################################################################
##############################################################################
type -P $REQUIREMENTS &>/dev/null || { echo "Missing Something ?" >&2; exit 1; }
shopt -s nocaseglob
set -e
echo -e '\E[37;44m\033[1mDVD to MPG Script\033[0m'
echo -en '\E[37;31m'"\033[1mCreating folders.\033[0m"
if [ ! -d "$dump" ]; then
echo '* Making dump directory'
mkdir -p $HOME/dvdrip/vob
mkdir -p $HOME/dvdrip/out
else
echo "* $dump exists."
fi
##############################################################################
##############################################################################
echo -en '\E[37;31m'"\033[1mTaking a VOB dump\033[0m"
vobcopy $vobargs "$dump"
##############################################################################
##############################################################################
echo '* Re-encoding with FFmpeg'
echo -en '\E[37;31m'"\033[1m* Re-encoding with FFmpeg\033[0m"
##############################################################################
##############################################################################
for vobinput in "$dump"/*.vob; do
dvdname=${vobinput%%/VIDEO_TS/*} dvdname=${dvdname##*/};
ffmpeg -i "$vobinput" $ffmpegargs "$output/${dvdname%.*}$format"
done
##############################################################################
##############################################################################
echo -en '\E[37;31m'"\033[1m* Deleting VOB dump\033[0m"
rm -rf $dump/*.*
##############################################################################
##############################################################################
echo -e '\E[47;32m\033[1mDone!\033[0m'
echo -en '\E[37;31m'"\033[1mScript By MystKid.\033[0m"
##############################################################################
###################################End########################################
##############################################################################
Last edited by MystKid (2011-02-27 02:33:59)
Offline
good script!thx
Offline
let me know if it works for you. i am adding an interactive menu at this moment. not sure when i will have it done. s
Offline
updated version. made it interactive. there are 4 options. one will rip the dvd in separate titles and one will rip the dvd in single title.
Edit: added verbose mode for option
#!/bin/bash
##Needed packages: vobcopy,ffmpeg,libdvdread,libdvdcss,libdvdread2-dev
shopt -s nocaseglob
set -e
echo -e "\E[37;44m\033[1mDVD to MPG Script\033[0m"
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,3,4)?
(Options 3,4 are 1,2 in verbose mode.)
Your choice:" option
# Option must be a valid integer; numbers lower than 1 or greater than 4 are invalid ...
if [[ $option =~ ^[[:digit:]]+$ ]] && [[ $option -lt 1 ]] || [[ $option -gt 4 ]]; then
echo -en "You didn't choose a valid option. Exiting! \E[37;31m\033[1mScript By MystKid.\033[0m"
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 -v -o"
elif [[ $option == "4" ]]; then
vobargs="-l -m -v -o"
fi
vobcopy $vobargs "$dumpdirectory"
echo "* Re-encoding with FFmpeg"
dvdname="$(vobcopy -I 2>&1 | grep DVD-name | sed 's/^.*: //')"
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"
let part="$part+1"
done
echo -e "\E[47;32m\033[1mDone!\033[0m"
echo -e "\E[37;31m\033[1mScript By MystKid.\033[0m"
##########################################By MystKid####################
Last edited by MystKid (2011-02-27 10:28:11)
Offline