From: Urban Wallasch Date: Mon, 31 May 2021 11:29:34 +0000 (+0200) Subject: * Added alternative method for counting subtitle streams using ffmpeg should ffprobe... X-Git-Tag: v0.4~3 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=b295e94cc8ae06e5084bb758c8d26b750b8e9757;p=ffpreview.git * Added alternative method for counting subtitle streams using ffmpeg should ffprobe fail. --- diff --git a/ffpreview.py b/ffpreview.py index b889c1c..edf6a59 100755 --- a/ffpreview.py +++ b/ffpreview.py @@ -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',