projects
/
rip_dvd
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleaned up description of handbrake cli vars.
[rip_dvd/.git]
/
rip_dvd
diff --git
a/rip_dvd
b/rip_dvd
index 18a1830b27bf1f53a78b49ffb2b227b4baf53d85..4b3223865d79d429311a2ea44a742d4ad94b277a 100755
(executable)
--- a/
rip_dvd
+++ b/
rip_dvd
@@
-3,7
+3,7
@@
# Author: Alan J. Pippin (apippin@pippins.net)
# Date: 05/17/2009
#
# Author: Alan J. Pippin (apippin@pippins.net)
# Date: 05/17/2009
#
- REV=2.
0
+ REV=2.
2
#
# Description: This script wraps a number of linux utilities to
# create a recipe for ripping protected DVDs, circumventing
#
# Description: This script wraps a number of linux utilities to
# create a recipe for ripping protected DVDs, circumventing
@@
-67,6
+67,9
@@
typeset -i audio_6ch=1
typeset -i invalid_feature_title=0
typeset -i feature_title_override=0
typeset -i mplayer_dumpstream_incompatibility=0
typeset -i invalid_feature_title=0
typeset -i feature_title_override=0
typeset -i mplayer_dumpstream_incompatibility=0
+typeset -i custom_bitrate=0
+typeset -i custom_audio_2ch=0
+typeset -i custom_audio_6ch=0
##############################################################################
# Local Machine Settings:
##############################################################################
# Local Machine Settings:
@@
-107,10
+110,10
@@
do
case $opt in
(n) dvdname=$OPTARG;;
(d) dest=$OPTARG;;
case $opt in
(n) dvdname=$OPTARG;;
(d) dest=$OPTARG;;
- (b) target_bitrate=$OPTARG;;
+ (b) target_bitrate=$OPTARG;
custom_bitrate=1;
;
(s) target_size=$OPTARG;;
(s) target_size=$OPTARG;;
- (2) audio_2ch=1;;
- (6) audio_6ch=1;;
+ (2) audio_2ch=1;
custom_audio_2ch=1;
;
+ (6) audio_6ch=1;
custom_audio_6ch=1;
;
(1) force_onepass_mode=1;;
(v) make_final_dest_vob=1;;
(i) make_final_dest_iso=1;;
(1) force_onepass_mode=1;;
(v) make_final_dest_vob=1;;
(i) make_final_dest_iso=1;;
@@
-278,6
+281,8
@@
fi
[[ ! -x `which makexml` ]] && echo "-E- missing dependency: makexml" && exit
[[ ! -x `which dvdauthor` ]] && echo "-E- missing dependency: dvdauthor" && exit
[[ ! -x `which mkisofs` ]] && echo "-E- missing dependency: mkisofs" && exit
[[ ! -x `which makexml` ]] && echo "-E- missing dependency: makexml" && exit
[[ ! -x `which dvdauthor` ]] && echo "-E- missing dependency: dvdauthor" && exit
[[ ! -x `which mkisofs` ]] && echo "-E- missing dependency: mkisofs" && exit
+[[ -n "$handbrake_xvid" ]] && [[ ! -x `which $handbrake_xvid` ]] && echo "-E- missing handbrake xvid encoder, set in rip_dvd.conf to: $handbrake_xvid" && exit
+[[ -n "$handbrake_mp4" ]] && [[ ! -x `which $handbrake_mp4` ]] && echo "-E- missing handbrake mp4 encoder, set in rip_dvd.conf to: $handbrake_mp4" && exit
[[ "$encoder" == "handbrake" ]] && [[ "$profile" =~ "xvid" ]] && [[ ! -x `which $handbrake_xvid` ]] && echo "-E- missing encoder: $handbrake_xvid" && exit
[[ "$encoder" == "handbrake" ]] && [[ "$profile" =~ "mp4" ]] && [[ ! -x `which $handbrake_mp4` ]] && echo "-E- missing encoder: $handbrake_mp4" && exit
[[ "$encoder" == "handbrake" ]] && [[ "$profile" =~ "ip" ]] && [[ ! -x `which $handbrake_mp4` ]] && echo "-E- missing encoder: $handbrake_mp4" && exit
[[ "$encoder" == "handbrake" ]] && [[ "$profile" =~ "xvid" ]] && [[ ! -x `which $handbrake_xvid` ]] && echo "-E- missing encoder: $handbrake_xvid" && exit
[[ "$encoder" == "handbrake" ]] && [[ "$profile" =~ "mp4" ]] && [[ ! -x `which $handbrake_mp4` ]] && echo "-E- missing encoder: $handbrake_mp4" && exit
[[ "$encoder" == "handbrake" ]] && [[ "$profile" =~ "ip" ]] && [[ ! -x `which $handbrake_mp4` ]] && echo "-E- missing encoder: $handbrake_mp4" && exit
@@
-472,6
+477,7
@@
function encode_vob_file_handbrake {
typeset filetype=""
typeset handbrake_audio_opts=""
typeset hb_profile=""
typeset filetype=""
typeset handbrake_audio_opts=""
typeset hb_profile=""
+ typeset SIZE=""
# Set a variable that we will use later to determine if we found a handler for $profile or not
typeset -i found_profile=0
# Set a variable that we will use later to determine if we found a handler for $profile or not
typeset -i found_profile=0
@@
-484,6
+490,10
@@
function encode_vob_file_handbrake {
# Set our DRC option
DRC="-D $drc"
# Set our DRC option
DRC="-D $drc"
+ if [ $target_size -ne 0 ]; then
+ SIZE="-S $target_size"
+ fi
+
# Check the global force_onepass_mode. If it is set, change our variables appropriately
# to force 1-pass encoding across all profiles.
if [ $force_onepass_mode -eq 1 ]; then
# Check the global force_onepass_mode. If it is set, change our variables appropriately
# to force 1-pass encoding across all profiles.
if [ $force_onepass_mode -eq 1 ]; then
@@
-533,6
+543,17
@@
function encode_vob_file_handbrake {
final_output_file="$dest/$dvdname.mp4"
PASSES=""
final_output_file="$dest/$dvdname.mp4"
PASSES=""
+ # Handle custom parameter overrides
+ if [ $custom_bitrate == 1 ]; then
+ handbrake_opts[0]="-b $target_bitrate"
+ fi
+ if [ $custom_audio_2ch == 0 ]; then
+ audio_2ch=0
+ fi
+ if [ $custom_audio_6ch == 0 ]; then
+ audio_6ch=0
+ fi
+
# Very High Quality
if [ "$profile" == "mp4vhq" ]; then
profile="hb_High_Profile"
# Very High Quality
if [ "$profile" == "mp4vhq" ]; then
profile="hb_High_Profile"
@@
-553,17
+574,27
@@
function encode_vob_file_handbrake {
handbrake_cli="$handbrake_mp4"
final_output_file="$dest/$dvdname.mp4"
PASSES=""
handbrake_cli="$handbrake_mp4"
final_output_file="$dest/$dvdname.mp4"
PASSES=""
- audio_2ch=1
- audio_6ch=0
+
+ # Handle custom parameter overrides
+ if [ $custom_bitrate == 1 ]; then
+ handbrake_opts[0]="-b $target_bitrate"
+ fi
+ if [ $custom_audio_2ch == 0 ]; then
+ audio_2ch=0
+ fi
+ if [ $custom_audio_6ch == 0 ]; then
+ audio_6ch=0
+ fi
# iphone
if [ "$profile" == "iphone" ]; then
# iphone
if [ "$profile" == "iphone" ]; then
- profile="hb_iPhone"
+ profile="hb_iPhone
_&_iPod_Touch
"
fi
# ipod
if [ "$profile" == "ipod" ]; then
profile="hb_iPod"
fi
fi
# ipod
if [ "$profile" == "ipod" ]; then
profile="hb_iPod"
fi
+
fi
# Predefined Handbrake Profile Handling
fi
# Predefined Handbrake Profile Handling
@@
-572,6
+603,17
@@
function encode_vob_file_handbrake {
handbrake_cli="$handbrake_mp4"
final_output_file="$dest/$dvdname.mp4"
PASSES=""
handbrake_cli="$handbrake_mp4"
final_output_file="$dest/$dvdname.mp4"
PASSES=""
+
+ # Handle custom parameter overrides
+ if [ $custom_bitrate == 1 ]; then
+ handbrake_opts[0]="-b $target_bitrate"
+ fi
+ if [ $custom_audio_2ch == 0 ]; then
+ audio_2ch=0
+ fi
+ if [ $custom_audio_6ch == 0 ]; then
+ audio_6ch=0
+ fi
# extract the HandBrake Profile name from $profile
hb_profile=`echo "$profile" | sed 's/hb_//g' | sed 's/_/ /g'`
# extract the HandBrake Profile name from $profile
hb_profile=`echo "$profile" | sed 's/hb_//g' | sed 's/_/ /g'`
@@
-612,8
+654,11
@@
function encode_vob_file_handbrake {
handbrake_cmd_line_opts="$handbrake_cmd_line_opts $PASSES"
handbrake_cmd_line_opts="$handbrake_cmd_line_opts $DRC"
handbrake_cmd_line_opts="$handbrake_cmd_line_opts $SCALE"
handbrake_cmd_line_opts="$handbrake_cmd_line_opts $PASSES"
handbrake_cmd_line_opts="$handbrake_cmd_line_opts $DRC"
handbrake_cmd_line_opts="$handbrake_cmd_line_opts $SCALE"
+ handbrake_cmd_line_opts="$handbrake_cmd_line_opts $SIZE"
# Execute the handbrake command to encode the video
# Execute the handbrake command to encode the video
+ # I have to copy-n-paste the code below to handle the 2 conditions, 1) hb_profile (mp4) 2) no hb_profile (xvid)
+ # The problem is the -Z "$hb_profile" option. I have to quote the "$hb_profile" due to spaces in it, forcing me to call it out explicity.
if [ -n "$hb_profile" ]; then
echo -e "\n Encoding: $handbrake_cli -i \"$vobfile\" -o \"$final_output_file\" -Z \"$hb_profile\" $handbrake_cmd_line_opts $handbrake_audio_opts $handbrake_video_encoder_opts >> $encodelog 2>&1" >> "$logfile"
$handbrake_cli -i "$vobfile" -o "$final_output_file" -Z "$hb_profile" $handbrake_cmd_line_opts $handbrake_audio_opts $handbrake_video_encoder_opts >> $encodelog 2>&1
if [ -n "$hb_profile" ]; then
echo -e "\n Encoding: $handbrake_cli -i \"$vobfile\" -o \"$final_output_file\" -Z \"$hb_profile\" $handbrake_cmd_line_opts $handbrake_audio_opts $handbrake_video_encoder_opts >> $encodelog 2>&1" >> "$logfile"
$handbrake_cli -i "$vobfile" -o "$final_output_file" -Z "$hb_profile" $handbrake_cmd_line_opts $handbrake_audio_opts $handbrake_video_encoder_opts >> $encodelog 2>&1
@@
-1059,14
+1104,15
@@
function get_audio_track_from_vob {
# find the stream that matches our aid
#stream=`grep "Stream.*\[0x$aid_hex\]" $aidcheck`
# find the stream that matches our aid
#stream=`grep "Stream.*\[0x$aid_hex\]" $aidcheck`
- stream=`grep "scan: audio" $aidcheck | grep -n "" | grep "scan: audio 0x$aid_hex"`
+ #stream=`grep "scan: audio" $aidcheck | grep -n "" | grep "scan: audio 0x$aid_hex"`
+ stream=`grep "add_audio_to_title:" $aidcheck | grep -n "" | grep "add_audio_to_title:.* stream 0x$aid_hex"`
# extract the track number that handbrake uses
#track=`expr match "$stream" '.*#[0-9]\.\([0-9]*\)'`
track=`expr match "$stream" '^\([0-9]*\):'`
if [ -n "$track" ]; then
# extract the track number that handbrake uses
#track=`expr match "$stream" '.*#[0-9]\.\([0-9]*\)'`
track=`expr match "$stream" '^\([0-9]*\):'`
if [ -n "$track" ]; then
- echo "
->
Setting the audio ID to $aid. Setting the audio track to $track." | tee -a "$logfile"
+ echo "
Setting the audio ID to $aid. Setting the audio track to $track." | tee -a "$logfile"
fi
}
fi
}
@@
-1203,6
+1249,7
@@
function calculate_bitrate_from_target_size {
if [ $target_size -ne 0 ]; then
vob_length=`mplayer -identify -v "$vobfile" -endpos 0 2>&1 | grep ID_LENGTH | awk -F '=' '{ print $2 }' | awk -F '.' '{ print $1 }'`
((target_bitrate = (target_size * 1024 * 8) / vob_length ))
if [ $target_size -ne 0 ]; then
vob_length=`mplayer -identify -v "$vobfile" -endpos 0 2>&1 | grep ID_LENGTH | awk -F '=' '{ print $2 }' | awk -F '.' '{ print $1 }'`
((target_bitrate = (target_size * 1024 * 8) / vob_length ))
+ custom_bitrate=1
echo " With a given target size of $target_size MB, the estimated bit rate will need to be $target_bitrate kbits/sec"
fi
}
echo " With a given target size of $target_size MB, the estimated bit rate will need to be $target_bitrate kbits/sec"
fi
}