X-Git-Url: http://git.pippins.net/embedvideo/.git/static/gitweb.js?a=blobdiff_plain;f=rip_dvd;h=521bf03f54502ecc93c261d4d79933c0aadbc697;hb=0ba7b0f48428f47a5ebf3600c07369eb3a594e2b;hp=a97a343fb8ba454554d5b85aa61176edd059cbe9;hpb=220c2fb1f8875f6c7876c7fe2f1f2b730460c4fc;p=rip_dvd%2F.git diff --git a/rip_dvd b/rip_dvd index a97a343..521bf03 100755 --- a/rip_dvd +++ b/rip_dvd @@ -62,6 +62,12 @@ fill_mythvideo_metadata=1 # Otherwise, you will need to rerun the script providing the feature title with the -t option. trust_feature_title_autodetect_when_uncertain=0 +# specify the number of threads that mencoder should use when encoding the video (AVI mode) +# an optimal setting for this should be the number of cores you have times 2 +# note: you have to have an mplayer version that has been compiled with multi thread support. +# if you don't, this will have no effect, but won't hurt anything to have it set otherwise. +mencoder_threads=8 + ############################################### # Command line processing typeset dvdname="" @@ -114,10 +120,11 @@ function usage() { echo >&2 "Revision $REV" echo >&2 "Options:" echo >&2 " -d Specify the destination directory to store the ripped DVD to" - echo >&2 " -n Specify what the name of the DVD is to process from $tmpdir" - echo >&2 " If dvdname is a full path to a DVD folder, it will be ripped as a DVD instead of $dev" - echo >&2 " If dvdname is a full path to an MPG2 file, it will be ripped as a DVD instead of $dev" - echo >&2 " This is optional. If not specified, the dvd will be pulled from $dev" + echo >&2 " -n Specify a path to a DVD folder or file to process:" + echo >&2 " 1) If this option is not specified, the DVD will be ripped from $dev" + echo >&2 " 2) If dvdname exists in $tmpdir, it will be ripped as a DVD instead of $dev" + echo >&2 " 3) If dvdname is a full path to a DVD folder, it will be ripped as a DVD instead of $dev" + echo >&2 " 4) If dvdname is a full path to an MPG2 file, it will be ripped as a DVD instead of $dev" echo >&2 " -m Make a mirror image of the DVD and save it as a DVD ISO file" echo >&2 " The default operation is non-mirror mode where only the main" echo >&2 " feature title will be ripped." @@ -239,9 +246,15 @@ if [ -z "$vobfile" ]; then vobfile="$dest/$dvdname.VOB" fi +# remove bad characters from the dvdname +dvdname=${dvdname%.} # remove trailing '.' character + +# make a "safe" dvdname (remove special characters) +safedvdname=`basename "$dvdname" | sed 's/[ !&*\\$?]/_/g'` + # set up some variables to hold various logfiles logfile="$logdir/$dvdname.log" -passlogfile="$tmpdir/divx2pass.log" +passlogfile="$tmpdir/$safedvdname.log" ddrescuelog=`tempfile` dvdauthorlog=`tempfile` encodelog=`tempfile` @@ -337,14 +350,24 @@ function make_dvd_iso_image_from_folder { echo " mkisofs -dvd-video \"$src\" 2>> \"$dumplog\" | dd of=\"$dst\" obs=32k seek=0 > /dev/null 2>> $dumplog" >> "$logfile" mkisofs -dvd-video "$src" 2>> "$dumplog" | dd of="$dst" obs=32k seek=0 > /dev/null 2>> "$dumplog" + # set the audio languages from the iso if it exists and is non-zero in size + if [ -s "$dst" ]; then + get_feature_title "$dst" + get_audio_id_from_iso "$dst" + fi + # make sure we were able to create the iso image from the folder given to us - if [ ! -s "$tmpdir/$dvdname.iso" ] && [ $handle_error -eq 1 ]; then + if [ ! -s "$dst" ] && [ $handle_error -eq 1 ]; then echo "-> Unable to make an iso image from the DVD folder: $dvdpath" echo " Falling back to mplayer to create a main feature VOB from the folder instead: $dvdpath" + # remove the bad iso file + [[ -e "$dst" ]] && rm -f "$dst" # get the feature title from the DVD folder get_feature_title "$dvdpath" # create our main VOB file from the ISO - create_main_vob_with_mplayer "$dvdpath" + create_main_vob_with_mplayer "$dvdpath" + # get our audio id from the VOB file + get_audio_id_from_vob "$vobfile" fi } @@ -454,9 +477,10 @@ function create_main_vob_with_mplayer { function get_audio_id_from_iso { # Adjust our audio ID to find the english audio stream # This should be 128. However, if 128 is not there, pick the next one that incrementally is. + iso="$1" aidcheck=`tempfile` aid=128 - mplayer -v -endpos 0 -dvd-device "$isofile" dvd://$feature_title > $aidcheck 2>&1 + mplayer -v -endpos 0 -dvd-device "$iso" dvd://$feature_title > $aidcheck 2>&1 grep -q "aid: $aid" $aidcheck while [ $? == 1 ] && [ $aid -lt 159 ]; do (( aid = aid + 1 )) @@ -495,9 +519,10 @@ function get_crop_from_iso { function get_audio_id_from_vob { # Adjust our audio ID to find the english audio stream # This should be 128. However, if 128 is not there, pick the next one that incrementally is. + vob="$1" aidcheck=`tempfile` aid=128 - mplayer -v -endpos 0 "$tmpdir/$dvdname.VOB" > $aidcheck 2>&1 + mplayer -v -endpos 0 "$vob" > $aidcheck 2>&1 grep -q "Found audio stream: $aid" $aidcheck while [ $? == 1 ] && [ $aid -lt 159 ]; do (( aid = aid + 1 )) @@ -839,7 +864,7 @@ if [ $mirror_mode -eq 0 ]; then if [ $use_mplayer_dumpstream -eq 1 ]; then # get our audio id from the ISO file - get_audio_id_from_iso + get_audio_id_from_iso "$isofile" # create our main VOB file from the ISO create_main_vob_with_mplayer "$isofile" @@ -862,7 +887,7 @@ if [ $mirror_mode -eq 0 ]; then create_main_vob_with_cat # get our audio id from the VOB file - get_audio_id_from_vob + get_audio_id_from_vob "$tmpdir/$dvdname.VOB" # check for corrupted VOB start check_vob_for_corrupted_start @@ -903,7 +928,7 @@ if [ $mirror_mode -eq 0 ]; then mencoder_general_opts="-quiet $lang_opts -passlogfile $passlogfile" mencoder_output_opts="-ofps 30000/1001 -ffourcc DIVX" mencoder_video_filter_opts="-vf pullup,softskip,hqdn3d=2:1:2$CROP" - mencoder_video_encoder_opts="-ovc xvid -xvidencopts pass=%PASS:chroma_opt:vhq=4:bvhq=1:quant_type=mpeg:bitrate=$target_bitrate:autoaspect:threads=2" + mencoder_video_encoder_opts="-ovc xvid -xvidencopts pass=%PASS:chroma_opt:vhq=4:bvhq=1:quant_type=mpeg:bitrate=$target_bitrate:autoaspect:threads=$mencoder_threads" # There are a number of different ways to encode 6 channel audio. # I've loaded 3 different ways into the mencoder_audioch_opts.