use File::stat;
use Time::localtime;
+# Early command line options processing
+getopts("rh: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 $find_cmd = "find \"$srcpathname/\" -cmin $minage -iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\"";
####################################################################################################
-# Command line options
-getopts("rh:tvs:");
-
sub usage {
print "usage: $0 [-tvrh] -s <srcpath>\n";
print " -s <srcpath> specify the path to search for videos to merge under\n";
print " -r remove merged video clips; after a merge, remove the individual video files that were merged\n";
return 1;
}
-my $srcpathname = $opt_s;
if(defined $opt_h) { usage(); exit 1; }
# Sanity checks
$newfile = $dstfile . "." . $video_suffix;
if(-e "$newfile.$ext") {
foreach $i ($video_suffix+1 .. '999') {
- $newfile = $dstfile . "." . $i;
+ $newfile = $dstfile . "." . sprintf("%03d",$i);
if(! -e "$newfile.$ext") { last; }
}
$dstfile = $newfile;
}
$dstfile = "$newfile.$ext";
- print " merging \"$srcdir/$srcfile\" into \"$dstfile\"\n";
push(@{$videos{"$dstfile"}}, "\"$srcdir/$srcfile\"");
}
+# Tell the user which videos we are going to merge
+foreach $video (sort keys %videos) {
+ # Only merge the videos if there is more than 1
+ my $num_videos = $#{$videos{$video}} + 1;
+ if($num_videos <= 1) { next; }
+
+ foreach $srcfile (@{$videos{$video}}) {
+ print " merging \"$srcfile\" into \"$video\"\n";
+ }
+}
+print "\n";
+
+# Now actually do the merging
foreach $video (sort keys %videos) {
my $videos = join(',', @{$videos{$video}});
} else {
# Create the merged video
my $errno = system("$cmd");
- if($errno > 0) { $errno = $errno - 255; }
+ $errno = $errno >> 8;
if($errno) { die "-E- make_mkv encountered some errors with exit code $errno\n"; }
# Fix the permissions
system("chown $owner \"$video\"");