Moved local configuration sourcing to occur after global variables are defined.
[rip_dvd/.git] / rip_dvd
diff --git a/rip_dvd b/rip_dvd
index da6b81fa98649b0004eb8125298bab6d3ffb6b45..754cda7c6d16746f3b8161ab17a32563d8bc9059 100755 (executable)
--- a/rip_dvd
+++ b/rip_dvd
 # lookup imdb info/posters for mythvideo: http://www.mythtv.org/wiki/Fill_mythvideo_metadata.pl
 #
 
-##############################################################################
-# Local Machine Settings:
-# Sources both the "default" conf file tracked by GIT (rip_dvd.conf.dist)
-# and the local conf file created by each local machine (rip_dvd.conf)
-# Copy the rip_dvd.conf.dist file to rip_dvd.conf and edit the later.
-# This will allow you to override all the default values to meet your needs
-# in a way that won't get clobbered when you pull updates from my GIT repo.
-##############################################################################
-config="${0%/*}/rip_dvd.conf"
-[ -e "${config}.dist" ] && . ${config}.dist
-[ -e "${config}" ] && . ${config}
-
 ##############################################################################################
-# Command line processing
+# Global Variables
 ##############################################################################################
+typeset cmd="$0 $*"
 typeset dvdname=""
 typeset debug=""
 typeset dest=""
@@ -71,6 +60,21 @@ typeset -i invalid_feature_title=0
 typeset -i feature_title_override=0
 typeset -i mplayer_dumpstream_incompatibility=0
 
+##############################################################################
+# Local Machine Settings:
+# Sources both the "default" conf file tracked by GIT (rip_dvd.conf.dist)
+# and the local conf file created by each local machine (rip_dvd.conf)
+# Copy the rip_dvd.conf.dist file to rip_dvd.conf and edit the later.
+# This will allow you to override all the default values to meet your needs
+# in a way that won't get clobbered when you pull updates from my GIT repo.
+##############################################################################
+config="${0%/*}/rip_dvd.conf"
+[ -e "${config}.dist" ] && . ${config}.dist
+[ -e "${config}" ] && . ${config}
+
+##############################################################################################
+# Command line processing
+##############################################################################################
 while (($#)) && getopts 12mvifkxht:n:d:b:s:t:a:p:e:j: opt "$@"
 do
     case $opt in
@@ -115,9 +119,9 @@ function usage() {
     echo >&2 "                 - xvidvhq = AVI, very high quality encoding, Xvid codec, 2 pass encoding (default)"
     echo >&2 "                 - xvidhq = AVI, high quality encoding, Xvid codec, 2 pass encoding"
     echo >&2 "                 - xvid = AVI, fast encoding, Xvid codec, 2 pass encoding"
-    echo >&2 "                 - mp4vhq = MP4, very high quality encoding, x264 codec, 2 pass encoding"
-    echo >&2 "                 - mp4hq = MP4, high quality encoding, x264 codec, 2 pass encoding"
-    echo >&2 "                 - mp4 = MP4, fast encoding, x264 codec, 2 pass encoding"
+    #echo >&2 "                 - mp4vhq = MP4, very high quality encoding, x264 codec, 2 pass encoding"
+    #echo >&2 "                 - mp4hq = MP4, high quality encoding, x264 codec, 2 pass encoding"
+    #echo >&2 "                 - mp4 = MP4, fast encoding, x264 codec, 2 pass encoding"
     echo >&2 "                 - iphone = MP4, x264 codec, 2 pass encoding, forced 480:320 scaling"
     echo >&2 "                 - ipod = MP4, x264 codec, 2 pass encoding, forced 320:240 scaling"
     echo >&2 "   -e <ext>      Specify a suffix extension to apply to the end of the final image filename (like .xvid, .ipod, etc)"
@@ -382,7 +386,7 @@ function encode_vob_file {
   passlogfile_opt="-passlogfile $passlogfile"
   pass_opt="pass=%PASS"
 
-  # Check the force_onepass_mode. If it is set, change our variables appropriately
+  # 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
     PASSES="2"
@@ -394,7 +398,7 @@ function encode_vob_file {
   if [ "$profile" == "xvid" ] || [ "$profile" == "xvidhq" ] || [ "$profile" == "xvidvhq" ]; then
     found_profile=1
     final_output_file="$dest/$dvdname.avi"
-    mencoder_general_opts="-quiet $lang_opts $passlogfile_opt"
+    mencoder_general_opts="$lang_opts $passlogfile_opt"
     mencoder_output_opts="-ofps 30000/1001 -ffourcc DIVX"
     mencoder_video_filter_opts="-vf pullup,softskip,hqdn3d=2:1:2$CROP$SCALE"
     mencoder_video_encoder_opts="-ovc xvid -xvidencopts $pass_opt"
@@ -448,10 +452,11 @@ function encode_vob_file {
   fi
 
   # MP4 encoding profiles
+  # These are currently in BETA. They don't work that great. A new recipe is needed, for the audio.
   if [ "$profile" == "mp4" ] || [ "$profile" == "mp4hq" ] || [ "$profile" == "mp4vhq" ]; then
     found_profile=1
     final_output_file="$dest/$dvdname.mp4"
-    mencoder_general_opts="-quiet $lang_opts $passlogfile_opt"
+    mencoder_general_opts="$lang_opts $passlogfile_opt"
     mencoder_output_opts="-ofps 30000/1001 -sws 9 -of lavf -lavfopts format=mp4"
     mencoder_video_filter_opts="-vf harddup$CROP$SCALE";
     mencoder_video_encoder_opts="-ovc x264 -x264encopts $pass_opt"
@@ -530,7 +535,7 @@ function encode_vob_file {
       SCALE=",dsize=320:240:0,scale=-8:-8"
     fi
     final_output_file="$dest/$dvdname.mp4"
-    mencoder_general_opts="-quiet $lang_opts $passlogfile_opt"
+    mencoder_general_opts="$lang_opts $passlogfile_opt"
     mencoder_output_opts="-ofps 30000/1001 -sws 9 -of lavf -lavfopts format=mp4"
     mencoder_video_filter_opts="-vf harddup$CROP$SCALE";
     mencoder_video_encoder_opts="-ovc x264 -x264encopts $pass_opt"
@@ -591,7 +596,7 @@ function encode_vob_file {
     fi
 
     # Concatenate the encode log to our main log file, greping out unwanted lines
-    cat $encodelog | grep -v "Pos:" >> "$logfile"
+    cat $encodelog | grep -v "^Pos:" | grep -v "duplicate" >> "$logfile"
 
   done
 }
@@ -1114,6 +1119,7 @@ function remove_intermediate_dvdbackup_folder {
 # Make a note of when this DVD rip started
 date=`date`
 echo -e "\n$date DVD rip started" >> "$logfile"
+echo "$cmd" >> "$logfile"
 
 # Rip the DVD - Mirror Mode
 if [ $mirror_mode -eq 1 ]; then