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 {
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;
}
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");
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");
}
}
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");
}
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");
}
}
}