* Added alternative method for counting subtitle streams using ffmpeg should ffprobe...
authorUrban Wallasch <urban.wallasch@freenet.de>
Mon, 31 May 2021 11:29:34 +0000 (13:29 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Mon, 31 May 2021 11:29:34 +0000 (13:29 +0200)
ffpreview.py

index b889c1c285d686aae5b2071f3c4e813dd9b87586..edf6a591b0cea8999fc672881c02d0f851260b34 100755 (executable)
@@ -1872,6 +1872,16 @@ def get_meta(vidfile):
     if rc == 0:
         meta['nsubs'] = len(out.splitlines())
         eprint(1, 'number of subtitle streams:', meta['nsubs'])
+    else: # ffprobe failed, try using ffmpeg
+        cmd = [cfg['ffmpeg'], '-i', vidfile]
+        out, err, rc = proc_cmd(cmd)
+        nsubs = 0
+        for line in io.StringIO(err).readlines():
+            if re.match(r'\s*Stream #.*: Subtitle:', line):
+                nsubs += 1
+        if nsubs > 0:
+            meta['nsubs'] = nsubs
+            eprint(1, 'number of subtitle streams:', meta['nsubs'])
     # get frames / duration / fps
     # try ffprobe fast method
     cmd = [cfg['ffprobe'], '-v', 'error', '-select_streams', 'v:0',