Added some code to correctly chown/chmod the playlists when they are created
[videoscripts/.git] / mkv_extract_chapter
index b70a7501db76507225bf6e638ff1ebd970be1be1..d8825ae2b7ed0f4f015e65840784730d4215a037 100755 (executable)
@@ -73,7 +73,7 @@ sub usage {
 # SUBROUTINES
 
 sub detect_ext {
-    my ($ffmpeg_info, $interlaced) = @_;
+    my ($ffmpeg_info, $progressive) = @_;
 
     my $h264 = 0;
     my $h264_high = 0;
@@ -94,9 +94,9 @@ sub detect_ext {
     # Quicktime/MOV
     if($h264 && $pcm_s16le) { return "mov"; }
     # MTS
-    if($h264_high && $ac3) { if($interlaced) { return "mkv"; } else { return "mp4"; } }
+    if($h264_high && $ac3) { if(!$progressive) { return "mkv"; } else { return "mp4"; } }
     # 3GP/MP4
-    if($h264 && $aac) { if($interlaced) { return "mkv"; } else { return "mp4"; } }
+    if($h264 && $aac) { if(!$progressive) { return "mkv"; } else { return "mp4"; } }
 
     return "UNKNOWN";
 }
@@ -118,8 +118,8 @@ my $all_chapters = 0;
 if($opt_c =~ /all/) { $all_chapters = 1; }
 print "-> Extracting the following chapters from $opt_i: @chapters\n";
 
-my $interlaced = system('ffmpeg -i "$opt_i" 2>&1 | grep -q "frame rate differs"');
-if($interlaced != 0) {
+my $progressive = system('ffmpeg -i "$opt_i" 2>&1 | grep -q "frame rate differs"');
+if(!$progressive) {
     print "   Detected interlaced video content\n";
 } else {
     print "   Detected progressive video content\n";
@@ -139,7 +139,7 @@ foreach $line (@ffmpeg_info) {
        if($all_chapters || &export_chapter(\@chapters,$chapter)) {
            $ext = "UNKNOWN"; 
            if(defined $opt_e) { $ext = $opt_e; }
-           else { $ext = &detect_ext(\@ffmpeg_info, $interlaced); } 
+           else { $ext = &detect_ext(\@ffmpeg_info, $progressive); } 
            if($ext =~ /UNKNOWN/) { die "-E- Unable to determine the file type/extension to use for the output videos. Specify it with the -e <ext> option.\n"; }
            $dstfile = $opt_o . ".c" . sprintf("%03d",$chapter) . "." . $ext;
            print "-> Exporting $chapter to $dstfile:\n";
@@ -153,7 +153,7 @@ foreach $line (@ffmpeg_info) {
                $errno = $errno >> 8;
                if($errno > 0) { die "-E- ffmpeg encountered some errors with exit code $errno\n"; }
            }
-           if($interlaced && $ext =~ /mkv/i) {
+           if(!$progressive && $ext =~ /mkv/i) {
                $ext = "mp4";
                $srcfile = $dstfile;
                $dstfile = $dstfile = $opt_o . ".c" . sprintf("%03d",$chapter) . "." . $ext;