From: Alan J. Pippin Date: Mon, 15 Feb 2010 16:56:36 +0000 (-0700) Subject: Added new check for VOBs that have bad length protection. X-Git-Tag: 2_4~1 X-Git-Url: http://git.pippins.net/embedvideo/.git/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/.%24link.?a=commitdiff_plain;h=4f86e282e7043687b6a702baa477b8a3024a0c4b;p=rip_dvd%2F.git Added new check for VOBs that have bad length protection. --- diff --git a/rip_dvd b/rip_dvd index 879920b..8919900 100755 --- a/rip_dvd +++ b/rip_dvd @@ -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 @@ -1249,9 +1250,21 @@ 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 ] && [ $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" | tee -a "$logfile" + ((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 { diff --git a/rip_dvd.conf.dist b/rip_dvd.conf.dist index 4b15b71..146f825 100644 --- a/rip_dvd.conf.dist +++ b/rip_dvd.conf.dist @@ -44,6 +44,14 @@ fill_mythvideo_metadata=0 # Otherwise, you will need to rerun the script providing the feature title with the -t option. trust_feature_title_autodetect_when_uncertain=0 +# Set what you expect to be the minimum feature title length. If the length of the DVD being +# ripped is detected to be less than this, throw out the calculated bitrate since it will be wrong. +# Some movies, like "The Saint", have VOBs created of the main feature whose length is incorrectly +# detected by mplayer. This makes the routine that converts target size into target bitrate get +# the wrong answer. In these cases, throw out the calculated bitrate, and rely on the bitrate +# provided on the command line. The units of this are in minutes. +minimum_feature_title_length=10 + # 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.