X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=merge_videos_by_day;h=4cf293ddea47cbd2b699faf4febcaa0fbe22fff7;hb=edc693952db5a6ff437046e6ee03be89c64ac62e;hp=9b8e2d74241fd36bb59f7685ba4cdd001d1d09cf;hpb=d0bb8d7ba0914fb2e31422aa1207ba6eaf490deb;p=videoscripts%2F.git diff --git a/merge_videos_by_day b/merge_videos_by_day index 9b8e2d7..4cf293d 100755 --- a/merge_videos_by_day +++ b/merge_videos_by_day @@ -9,24 +9,17 @@ use File::stat; use Time::localtime; # Early command line options processing -getopts("qrh:tvs:"); +getopts("qkh:tvs:"); my $srcpathname = $opt_s; #################################################################################################### -# Configuration parameters - CHANGE THESE TO SUITE YOUR NEEDS -my $compute_host = "pippin.pippins.net"; # I need this since this script is run from a virtual machine -my $use_compute_host = 1; # Set to 1 to use a remote compute host to run the mkvmerge command. Set to 0 to use the local host to run it. -my $make_mkv = "/naspool/videos/bin/make_mkv"; # Update this to be the path to the make_mkv script -my $requantize_input_video=1; # This will dramatically decrease the size of the video with minimal compute processing requirements. -my $owner = "ajp"; # The owner of the files after they are moved -my $group = "pip"; # The group of the files after they are moved -my $mode = "664"; # The mode to set on each file after they are moved -my $video_suffix = "000"; # What number to start with when adding an incrementing suffix to the end of the video clip to avoid name collisons -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 $interlaced_requantize_quality=0.85; -my $progressive_requantize_quality=0.7; +# Configuration parameters +$mydir = `cd \$(dirname $0) 2>/dev/null; pwd`; chomp($mydir); unshift @INC,("$mydir"); +# Default configuration values +require "organize_videos.conf"; +# Override defaults with local customizations +if( -f "$mydir/organize_videos.conf.local") { require "organize_videos.conf.local"; } + #################################################################################################### sub usage { @@ -35,7 +28,7 @@ sub usage { print " -h 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 +217,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 +227,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 +272,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"); } @@ -289,14 +282,15 @@ foreach $ext (sort keys %videos) { my $errno = system("$cmd"); $errno = $errno >> 8; if($errno) { die "-E- make_mkv encountered some errors with exit code $errno\n"; } + system("ls -l \"$srcpathname/\" > /dev/null"); # Make sure the video file is there # Fix the permissions system("chown $owner \"$video\""); system("chgrp $group \"$video\""); system("chmod $mode \"$video\""); # Remove the individual video files - if(defined $opt_r) { - foreach $video (@{$videos{$ext}{$video}}) { - system("rm -f $video"); + if(!defined $opt_k) { + foreach $srcvideo (@{$videos{$ext}{$video}}) { + system("rm -f $srcvideo"); } } }