ts2mkv.py

changeset 26
361f76cd60ee
parent 25
078802773343
child 27
a2951f7c435e
--- a/ts2mkv.py	Thu Dec 07 16:15:40 2017 +0100
+++ b/ts2mkv.py	Mon Dec 11 22:45:18 2017 +0100
@@ -218,9 +218,9 @@
             else:
                 if option != tmp:
                     failcount += 1
-                    if failcount > 12:
+                    if failcount > 6:
                         print "!!! Crop detect is inconsistent"
-                        self.info["msg_prepare"] += "WARNING: cropdetect >50% inconsistent over scan time, disabling autocrop\n"
+                        self.info["msg_prepare"] += "WARNING: cropdetect inconsistent, disabling autocrop\n"
                         return None
         self.info["msg_prepare"] += "Crop detected: %s\n" % option
         return option
@@ -297,13 +297,13 @@
         print "Total frames of input file: %i" % (self.info["frames_total"])
 
 
-    def __get_ffmpeg_input_info(self, filename):
+    def __get_ffmpeg_input_info(self, filename, crop_minute = 5):
         """
         Run ffmpeg for cropdetect and general input information
         """
         cmd = [
             "ffmpeg", "-hide_banner",
-            "-ss 00:05:00", "-t 2", # search to 5 minutes, analyze 2 seconds
+            "-ss 00:%02i:00" % crop_minute, "-t 1", # search to 5 minutes, analyze 1 seconds
             "-i %s" % filename,
             "-vf \"cropdetect=24:2:0\"", # detect black bar crop on top and bottom
             "-f null", "-" # no output file
@@ -408,6 +408,14 @@
 
         flt = []
         crop = self.get_crop_option()
+        if not crop:
+            # load input file to get informations about
+            # scan to other position and try again
+            print "Scanning again for autocrop..."
+            self.info["msg_prepare"] += "Rescan autocrop on other position in input stream...\n"
+            self.__get_ffmpeg_input_info(fn["in"], 9)
+            crop = self.get_crop_option()
+
         if crop:
             flt.append(crop)
         if self.config["scaledown"]:
@@ -492,11 +500,14 @@
     processor.config["overwrite"] = args.f
     processor.config["firstaudio"] = args.fa
 
+    src = []
     for srcstr in args.input:
-        src = glob.glob(srcstr)
-        for srcfile in src:
-            print "Processing: %s" % srcfile
-            processor.load(srcfile)
-            processor.convert()
+        src.extend(glob.glob(srcstr))
+    idx = 1
+    for srcfile in src:
+        print "\nProcessing file %i/%i: %s" % (idx, len(src), srcfile)
+        processor.load(srcfile)
+        processor.convert()
+        idx += 1
 
 

mercurial