X-Git-Url: http://git.pippins.net/embedvideo/.git/static/gitweb.js?a=blobdiff_plain;ds=sidebyside;f=rip_dvd;h=4f9c968d7171770750aac64483a38f165f3a5d30;hb=1c24fa012d631668dfdf678b22a1ddd23019bef8;hp=e025e5705863918c5c9526adf4d48600c5eed8ea;hpb=6e9e0c34ec53f0ce22bdf993da8fa50beeb0b275;p=rip_dvd%2F.git diff --git a/rip_dvd b/rip_dvd index e025e57..4f9c968 100755 --- a/rip_dvd +++ b/rip_dvd @@ -3,7 +3,7 @@ # Author: Alan J. Pippin (apippin@pippins.net) # Date: 05/17/2009 # - REV=2.3 + REV=2.4 # # Description: This script wraps a number of linux utilities to # create a recipe for ripping protected DVDs, circumventing @@ -65,6 +65,7 @@ typeset -i custom_video_bitrate=0 typeset -i custom_audio_bitrate=0 typeset -i custom_audio_2ch=0 typeset -i custom_audio_6ch=0 +typeset -i minimum_feature_title_length=10 ############################################################################## # Local Machine Settings: @@ -985,7 +986,7 @@ function create_main_vob_with_mplayer { # check to make sure we didn't detect an mplayer dumpstream incompatibility earlier if [ $mplayer_dumpstream_incompatibility -eq 1 ]; then msg="-E- We detected an mplayer dumpstream incompatibility earlier." - msg="$msg We also detected another condition that requires us to use dumpstream. " + msg="$msg We also detected a condition that may require you to use dumpstream. " msg="$msg\n Unable to rip this DVD in the mode you requested." fatal_and_exit "$msg" fi @@ -1101,7 +1102,7 @@ function get_audio_track_from_vob { # extract the audio streams in the vob #ffmpeg -i "$vob" > $aidcheck 2>&1 - $handbrake_cli --stop-at 0 -i "$vob" -o /dev/null -v 100 > $aidcheck 2>&1 + $handbrake_cli --stop-at duration:1 -i "$vob" -o /dev/null -v 100 > $aidcheck 2>&1 # find the stream that matches our aid #stream=`grep "Stream.*\[0x$aid_hex\]" $aidcheck` @@ -1247,11 +1248,23 @@ function check_vob_for_a52_crc_errors { function calculate_bitrate_from_target_size { # determine what our bitrate needs to be if a target size was specified instead - if [ $target_size -ne 0 ]; then + if [ $target_size -ne 0 ] && [ $custom_video_bitrate -eq 0 ]; then vob_length=`mplayer -identify -v "$vobfile" -endpos 0 2>&1 | grep ID_LENGTH | awk -F '=' '{ print $2 }' | awk -F '.' '{ print $1 }'` - ((target_video_bitrate = (target_size * 1024 * 8) / vob_length )) - custom_video_bitrate=1 - echo " With a given target size of $target_size MB, the estimated bit rate will need to be $target_video_bitrate kbits/sec" + ((min_length = minimum_feature_title_length * 60)) + if [[ $vob_length -gt $min_length ]]; then + ((target_video_bitrate = (target_size * 1024 * 8) / vob_length )) + custom_video_bitrate=1 + echo " With a given target size of $target_size MB, the estimated bit rate will need to be $target_video_bitrate kbits/sec" | tee -a "$logfile" + else + echo "-W- Unable to determine the real length of this DVD feature title." | tee -a "$logfile" + echo " A target bitrate from the target_size requested will not be set." | tee -a "$logfile" + echo " If using handbrake, only the target_size will be passed to the encoder." | tee -a "$logfile" + echo " If using mencoder, the target_size will be entirely disregarded." | tee -a "$logfile" + echo " You may need to rerun with the -b option with a target bitrate to get the desired size." | tee -a "$logfile" + if [[ $encoder -ne "handbrake" ]] || [[ "$profile" =~ "xvid" ]]; then + fatal_and_exit "-E- You'll need rip this DVD with the handbrake encoder and an MP4 type profile to get a good rip." + fi + fi fi } @@ -1353,6 +1366,20 @@ function check_for_mplayer_dumpstream_incompatibility { fi [[ -e "$dumplog" ]] && rm -f $dumplog fi + + # There is another form of protection that causes the mplayer dumpstream to fail. + # The resulting VOB file looks complete, but has something in it that causes mplayer/mencoder + # to be unable to encode it since it thinks the entire VOB is only a few minutes long in length. + # Using HandBrake with an MP4 type profile can work around this, but mencoder or Handbrake with XVID profile won't. + vob_length=`mplayer -identify -v "$vobfile" -endpos 0 2>&1 | grep ID_LENGTH | awk -F '=' '{ print $2 }' | awk -F '.' '{ print $1 }'` + ((min_length = minimum_feature_title_length * 60)) + if [[ $vob_length -lt $min_length ]]; then + if [[ $encoder -ne "handbrake" ]] || [[ "$profile" =~ "xvid" ]]; then + echo "-E- The main feature title that was ripped from the DVD has an invalid movie length." | tee -a "$logfile" + echo " You'll need rip this DVD with the handbrake encoder and an MP4 type profile instead." | tee -a "$logfile" + mplayer_dumpstream_incompatibility=1 + fi + fi } function fill_mythvideo_metadata {