From: Alan J. Pippin Date: Tue, 5 Apr 2016 03:54:03 +0000 (-0600) Subject: Added some required binary checks. Added save originals functionality. X-Git-Url: http://git.pippins.net/embedvideo/.git/static/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/%7Blink_ppi%7D?a=commitdiff_plain;h=4ad705a6bce59141854f071467f734ee442c544f;p=videoscripts%2F.git Added some required binary checks. Added save originals functionality. --- diff --git a/make_mkv b/make_mkv index 04557b5..805a7f5 100755 --- a/make_mkv +++ b/make_mkv @@ -5,6 +5,7 @@ # Pre-requisites: # mkvtoolnix - http://www.bunkus.org/videotools/mkvtoolnix/ # ffmpeg +# avconv #################################################################################################### # Includes @@ -31,6 +32,8 @@ getopts("svqzt:o:i:h"); if(! defined $opt_t) { &usage(); die "-E- Missing required title: -t \n"; } if(! defined $opt_o) { &usage(); die "-E- Missing required argument output video names: -o <output.mkv>\n"; } if(! defined $opt_i) { &usage(); die "-E- Missing required argument input video names: -i <input,input,...>\n"; } +if(! -x $ffmpeg) { die "-E- Missing required executable for ffmpeg: $ffmpeg\n"; } +if(! -x $avconv) { die "-E- Missing required executable for avconv: $avconv\n"; } sub usage { print "usage: $0 -t <title> -o <output.mkv> -i <input,input,...>\n"; @@ -130,10 +133,10 @@ foreach my $video (sort{$videos{$a} <=> $videos{$b}} keys %videos) { my $video_mkv = $video; print " Detected interlaced video content: $video\n"; # We don't need to do this anymore since it is not an issue with the new mkvmerge - if(0 && $video_ext !~ /mkv/i) { + if($video_ext !~ /mkv/i) { $video_mkv =~ s/\.[^.]*$//; $video_mkv .= ".ffmpeg.mkv"; print " Re-muxing the interlaced video content as an mkv file: $video_mkv\n"; - my $make_mkv_cmd = "$ffmpeg -y -i \"$video\" -scodec copy -acodec copy -vcodec copy -f matroska \"$video_mkv\" >> \"$tmpfile\" 2>&1"; + my $make_mkv_cmd = "$avconv -y -i \"$video\" -scodec copy -acodec copy -vcodec copy -f matroska \"$video_mkv\" >> \"$tmpfile\" 2>&1"; if($opt_v) { print " $make_mkv_cmd\n"; } if(! defined $opt_s) { my $errno = system("$make_mkv_cmd"); diff --git a/merge_videos_by_day b/merge_videos_by_day index 6e7998c..e164bee 100755 --- a/merge_videos_by_day +++ b/merge_videos_by_day @@ -94,7 +94,7 @@ foreach $file (sort `$find_cmd`) { $date_taken = ctime(stat("$srcdir/$srcfile")->mtime); # Get the date taken from the filename - if($srcfile =~ /^(\d+)-(\d+)-(\d+)/) { + if(!$merge_by_modification_date && $srcfile =~ /^(\d+)-(\d+)-(\d+)/) { $year = $1; $month = $2; $day = sprintf("%02d",$3); @@ -194,7 +194,16 @@ foreach $ext (sort keys %videos) { print "$cmd\n"; if(!defined $opt_k) { foreach $video (@{$videos{$ext}{$video}}) { - print("rm -f $video\n"); + if($save_originals) { + print "-> Saving the original video $video\n"; + if($video =~ /\.$originals_file_ext/) { + print("mv $video \"$origpathname/".basename(dirname($video))."_".basename($video)."\n"); + $video = ""; + } + } + if(-e $video) { + print("rm -f $video\n"); + } } } } else { @@ -210,7 +219,16 @@ foreach $ext (sort keys %videos) { # Remove the individual video files if(!defined $opt_k) { foreach $srcvideo (@{$videos{$ext}{$video}}) { - system("rm -f $srcvideo"); + if($save_originals) { + print "-> Saving the original video $srcvideo to $origpathname\n"; + if($srcvideo =~ /\.$originals_file_ext/) { + system("mv $srcvideo \"$origpathname/".basename(dirname($srcvideo))."_".basename($srcvideo)); + $srcvideo = ""; + } + } + if(-e $srcvideo) { + system("rm -f $srcvideo"); + } } } } diff --git a/organize_videos.conf b/organize_videos.conf index c13e406..a4c06b4 100644 --- a/organize_videos.conf +++ b/organize_videos.conf @@ -12,25 +12,34 @@ ################################################################################ # Path to look for videos to move from -$srcpathname = "/naspool/pictures/New Photos"; +$srcpathname = "/naspool/dropbox/New Memories"; # Path to move the videos to $dstpathname = "/naspool/videos/HomeVideos"; +# Path to move the originals to +$origpathname = "/naspool/dropbox/Originals"; +$originals_file_ext = qr/mov/i; +$save_originals = 1; + # Path to merge_videos_by_day script $merge_videos_by_day = "/naspool/videos/bin/merge_videos_by_day"; +# Flag to merge videos by modification date instead of the date parsed from the filename +$merge_by_modification_date = 1; + # Path to the make_mkv script $make_mkv = "/naspool/videos/bin/make_mkv"; # mkvmerge path/command name -$mkvmerge = 'mkvmerge'; +$mkvmerge = '/usr/bin/mkvmerge'; # ffmpeg path/command name -$ffmpeg = 'ffmpeg'; +$ffmpeg = '/usr/bin/ffmpeg'; +$avconv = '/usr/bin/avconv'; # handbrake path/command name -$handbrake = 'HandBrakeCLI'; +$handbrake = '/usr/bin/HandBrakeCLI'; # The pid file to use to indicate organize_videos is running $pid_file = "/tmp/organize_videos.pid"; @@ -95,7 +104,7 @@ $progressive_requantize_quality=0.75; $compute_host = "pippin.pippins.net"; # 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. -$use_compute_host = 1; +$use_compute_host = 0; # This will dramatically decrease the size of the video with minimal compute processing requirements. $requantize_input_video=0;