Fixed missing strict-anamorphic mode for HandBrake.
[videoscripts/.git] / merge_videos_by_day
index 9b8e2d74241fd36bb59f7685ba4cdd001d1d09cf..4d96b93be7438260d6106c056831a9f01b247d4f 100755 (executable)
@@ -9,7 +9,7 @@ use File::stat;
 use Time::localtime;
 
 # Early command line options processing
-getopts("qrh:tvs:");
+getopts("qkh:tvs:");
 my $srcpathname = $opt_s;
 
 ####################################################################################################
@@ -25,6 +25,7 @@ my $video_suffix = "000"; # What number to start with when adding an incrementin
 my $video_title_prefix = "HomeVideos:"; # What text to put on the front of the title for the merged video being created
 my $find_cmd = "find \"$srcpathname/\" -iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\"";
 my $handbrake='HandBrakeCLI';
+my $handbrake_options='--strict-anamorphic --crop 0:0:0:0 -E ac3';
 my $interlaced_requantize_quality=0.85;
 my $progressive_requantize_quality=0.7;
 ####################################################################################################
@@ -35,7 +36,7 @@ sub usage {
     print "   -h <compute host>     specify the remote compute host to submit the mkvmerge job to\n";
     print "   -v                    verbose mode; print extra information about what is being found/merged\n";
     print "   -t                    test mode; print what will happen, but don't do anything\n";
-    print "   -r                    remove merged video clips; after a merge, remove the individual video files that were merged\n";
+    print "   -k                    keep the individual video files that are merged. By default, after a merge, individual video files that were merged are removed\n";
     print "   -q                    Requantize MTS input videos to decrease output video size (requires HandBrakeCLI)\n";
     return 1;
 }
@@ -224,7 +225,7 @@ foreach $ext (sort keys %videos) {
                print "   Re-quantizing input video content: $video\n";
                my $handbrake_cmd = "";
                if($use_compute_host) { $handbrake_cmd .= "ssh $compute_host 'cd \"$pwd\";"; }
-               $handbrake_cmd .= "$handbrake $deinterlace_option $requantize_option -E ac3 -i $srcvideo -o \"$video\" > /dev/null 2>&1";
+               $handbrake_cmd .= "$handbrake $deinterlace_option $requantize_option $handbrake_options -i $srcvideo -o \"$video\" > /dev/null 2>&1";
                if($use_compute_host) { $handbrake_cmd .= "'"; }
                if(! defined $opt_t) { 
                    my $errno = system("$handbrake_cmd");
@@ -234,7 +235,7 @@ foreach $ext (sort keys %videos) {
                        die "-E- handbrake encountered some errors with exit code $errno\n";
                    } else {
                        # Remove the original srcvideo since we created a new version of it that we are going to keep instead
-                       if(defined $opt_r) { 
+                       if(!defined $opt_k) { 
                            system("rm -f $srcvideo\n");
                        }
                    }
@@ -279,7 +280,7 @@ foreach $ext (sort keys %videos) {
        if(defined $opt_t) {
            print "\n-> Creating \"$video\"\n";
            print "$cmd\n";
-           if(defined $opt_r) { 
+           if(!defined $opt_k) { 
                foreach $video (@{$videos{$ext}{$video}}) {
                    print("rm -f $video\n");
                }
@@ -294,7 +295,7 @@ foreach $ext (sort keys %videos) {
            system("chgrp $group \"$video\"");
            system("chmod $mode \"$video\"");
            # Remove the individual video files
-           if(defined $opt_r) { 
+           if(!defined $opt_k) { 
                foreach $video (@{$videos{$ext}{$video}}) {
                    system("rm -f $video");
                }