From: Urban Wallasch Date: Sun, 9 May 2021 13:44:30 +0000 (+0200) Subject: * Fixed broken ffprobe invocation. X-Git-Tag: v0.1^0 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=c1296fc4f54f96de25452a60685028adc90402e0;p=ffpreview.git * Fixed broken ffprobe invocation. --- diff --git a/ffpreview.py b/ffpreview.py index 84d7f04..7f3a9e0 100755 --- a/ffpreview.py +++ b/ffpreview.py @@ -398,8 +398,8 @@ def get_meta(vidfile): global proc # try ffprobe method try: - cmd = cfg['ffprobe'] + ' -v error -select_streams v -of json' - cmd += ' -show_entries stream=nb_frames:stream=duration' + cmd = cfg['ffprobe'] + ' -v error -select_streams v:0 -of json -count_packets' + cmd += ' -show_entries format=duration:stream=nb_read_packets' cmd += ' "' + vidfile + '"' proc = Popen('exec ' + cmd, shell=True, stdout=PIPE, stderr=PIPE) stdout, stderr = proc.communicate() @@ -407,8 +407,8 @@ def get_meta(vidfile): proc = None if retval == 0: info = json.loads(stdout.decode()) - meta['frames'] = int(info['streams'][0]['nb_frames']) - d = float(info['streams'][0]['duration']) + meta['frames'] = int(info['streams'][0]['nb_read_packets']) + d = float(info['format']['duration']) meta['duration'] = int(d) meta['fps'] = round(meta['frames'] / d, 2) return meta @@ -416,8 +416,7 @@ def get_meta(vidfile): eprint(cmd) eprint(stderr.decode()) except Exception as e: - eprint(cmd) - eprint(str(e)) + eprint(cmd + '\n failed: ' + str(e)) # ffprobe didn't cut it, try ffmpeg instead try: cmd = cfg['ffmpeg'] + ' -nostats -i "' + vidfile + '"' @@ -439,8 +438,7 @@ def get_meta(vidfile): eprint(cmd) eprint(stderr.decode()) except Exception as e: - eprint(cmd) - eprint(str(e)) + eprint(cmd + '\n failed: ' + str(e)) return meta # extract thumbnails from video and collect timestamps