# 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
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:
# 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
# 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`
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
}
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 {