fix: cropdetect

Thu, 04 Oct 2018 00:43:26 +0200

author
mdd
date
Thu, 04 Oct 2018 00:43:26 +0200
changeset 34
344802cf307d
parent 33
83bcb5931ee3
child 35
14c966c10648

fix: cropdetect

ts2mkv.py file | annotate | diff | comparison | revisions
--- a/ts2mkv.py	Thu Oct 04 00:42:48 2018 +0200
+++ b/ts2mkv.py	Thu Oct 04 00:43:26 2018 +0200
@@ -201,6 +201,8 @@
         parse the ffmpeg analyze output cropdetect lines
         returns None or valid crop string for ffmpeg video filter
         """
+        if not self.config["cropdetect"]:
+            return None
         lines = filter_lines(self.info["msg_ffmpeg"], "[Parsed_cropdetect").split("\n")
         option = None
         failcount = 0
@@ -210,9 +212,13 @@
             if len(tmp.split(":")) != 4:
                 print "Warning, invalid cropdetect: %s" % tmp
                 return None
-            if tmp.split(":")[2] != "0":
-                print "!!! X crop detected, disabling autocrop (%s)" % tmp
-                self.info["msg_prepare"] += "WARNING: cropdetect suggested X crop, disabling autocrop\n"
+            try:
+                if int(tmp.split(":")[2]) > 4:
+                    print "!!! X crop detected, disabling autocrop (%s)" % tmp
+                    self.info["msg_prepare"] += "WARNING: cropdetect suggested X crop, disabling autocrop\n"
+                    return None
+            except ValueError:
+                print "invalid crop x shift value, ignoring autocrop"
                 return None
             #print "DEBUG: " + tmp
             if not option:
@@ -490,6 +496,8 @@
         help='ffmpeg tune preset [film, animation] (default is film)')
     parser.add_argument('--ns', action='store_true', default=False, \
         help='no rescaling (default is scale to 720p)')
+    parser.add_argument('--nc', action='store_true', default=False, \
+        help='no crop detection')
     parser.add_argument('-f', action='store_true', default=False, \
         help='force overwrite of existing file')
     parser.add_argument('--fa', action='store_true', default=False, \
@@ -506,6 +514,7 @@
     args = parser.parse_args()
     processor = ts2mkv(crf=args.crf, tune=args.tune)
     processor.config["scaledown"] = not args.ns
+    processor.config["cropdetect"] = not args.nc
     processor.config["rename"] = args.rename
     processor.config["overwrite"] = args.f
     processor.config["firstaudio"] = args.fa

mercurial