force first audio stream option

Wed, 29 Nov 2017 18:00:32 +0100

author
mdd
date
Wed, 29 Nov 2017 18:00:32 +0100
changeset 20
5b433bdd2023
parent 19
3a9fd72717df
child 21
1c0beeca2f9c

force first audio stream option

ts2mkv.py file | annotate | diff | comparison | revisions
--- a/ts2mkv.py	Tue Nov 28 22:49:41 2017 +0100
+++ b/ts2mkv.py	Wed Nov 29 18:00:32 2017 +0100
@@ -245,6 +245,12 @@
             # append english audio too!
             print "Selecting english ac3 stream."
             audiomap.append(aidx)
+        if len(audiomap) == 0 and self.config["firstaudio"]:
+            # append first audio stream as forced fallback
+            aidx = self.get_stream_index(audioall)
+            if aidx != "":
+                print "Forcing first found audio stream: %s" % aidx
+                audiomap.append(aidx)
         return audiomap
 
     def __parse_info(self):
@@ -428,6 +434,8 @@
         """
         if not self.command:
             return None
+        if not self.info["msg_eit"]:
+            self.info["msg_eit"] = "No EIT file found, sorry - no description"
         fd = open(self.outfilebase + ".txt", "wb")
         fd.write(self.info["msg_eit"])
         fd.write("\n\n# ---DEBUG---\n\n")
@@ -460,12 +468,15 @@
         help='one or more files, glob style syntax')
     parser.add_argument('-f', action='store_true', default=False, \
         help='force overwrite of existing file')
+    parser.add_argument('--fa', action='store_true', default=False, \
+        help='use first audio stream found')
 
     args = parser.parse_args()
     processor = ts2mkv(crf=args.crf, tune=args.tune)
     processor.config["scaledown"] = not args.ns
     processor.config["rename"] = args.rename
     processor.config["overwrite"] = args.f
+    processor.config["firstaudio"] = args.fa
 
     for srcstr in args.input:
         src = glob.glob(srcstr)

mercurial