From: Alan J. Pippin Date: Fri, 18 Nov 2011 04:08:42 +0000 (-0700) Subject: Bug fixes X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/%7Blink_visit%7D?a=commitdiff_plain;h=75913896fe5842b5783d61a8a0c9b709940faf5d;p=videoscripts%2F.git Bug fixes --- diff --git a/merge_videos_by_day b/merge_videos_by_day index 6d48bfc..52164d4 100755 --- a/merge_videos_by_day +++ b/merge_videos_by_day @@ -8,6 +8,10 @@ use Getopt::Std; 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 @@ -22,9 +26,6 @@ my $video_title_prefix = "HomeVideos:"; # What text to put on the front of the t 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 \n"; print " -s specify the path to search for videos to merge under\n"; @@ -34,7 +35,6 @@ sub usage { 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 @@ -128,10 +128,21 @@ foreach $file (sort `$find_cmd`) { } $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"; + } +} + +# Now actually do the merging foreach $video (sort keys %videos) { my $videos = join(',', @{$videos{$video}});