# Pre-requisites:
# mkvtoolnix - http://www.bunkus.org/videotools/mkvtoolnix/
# ffmpeg
+# avconv
####################################################################################################
# Includes
if(! defined $opt_t) { &usage(); die "-E- Missing required title: -t <title>\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";
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");
$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);
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 {
# 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");
+ }
}
}
}
################################################################################
# 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";
$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;