Added some required binary checks. Added save originals functionality.
[videoscripts/.git] / make_mkv
index 04557b5ef788ea6e4aacc6d789a55ed5bf4da795..805a7f5d9300de309c0e5a60e6a329a7e439816a 100755 (executable)
--- 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 <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";
@@ -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");