ffmpeg concatenate multiple input files .ts .ts.NNN

Sat, 25 Nov 2017 13:08:41 +0100

author
mdd
date
Sat, 25 Nov 2017 13:08:41 +0100
changeset 12
f0c7db3b239d
parent 11
821c02fa7070
child 13
cf5c5cec1b2b

ffmpeg concatenate multiple input files .ts .ts.NNN

ts2mkv.py file | annotate | diff | comparison | revisions
--- a/ts2mkv.py	Sat Nov 25 12:24:17 2017 +0100
+++ b/ts2mkv.py	Sat Nov 25 13:08:41 2017 +0100
@@ -231,6 +231,28 @@
 
         # TODO: Old dreambox images did a file split: .ts .ts.001 .ts.002 etc.
         # Find all these files and join them!
+        inputs = [fn]
+        if os.path.splitext(fn)[1].lower() == '.ts':
+            for fpart in glob.glob(self.filename + '.' + ('[0-9]' * 3)):
+                fn = "\\'".join(p for p in fpart.split("'"))
+                fn = fn.replace(" ", "\\ ")
+                inputs.append(fn)
+                #inputs.append(shlex.split(fpart))
+
+        if len(inputs) > 1:
+            # use ffmpeg input concat function
+            # attention, ffmpeg doesnt like escape sequences
+            fn = "\"concat:" + \
+                "|".join(inputs)\
+                .replace('\ ', ' ')\
+                .replace("\'", "'")\
+                + "\""
+
+        idx = 0
+        for tmp in inputs:
+            self.msg_prepare += "Input file #%i: %s\n" % (
+                idx, os.path.basename(tmp))
+            idx += 1
 
         cmd = [
             "ffmpeg",

mercurial