From 20e523ad2c0cfbea9fff0baaa3fa649f0f9f6e1e Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Wed, 26 May 2021 12:30:56 +0200 Subject: [PATCH] * Fixed two instances of potential dividion by zero. --- ffpreview.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffpreview.py b/ffpreview.py index bfcd24e..eb7dbdb 100755 --- a/ffpreview.py +++ b/ffpreview.py @@ -1713,8 +1713,8 @@ def get_meta(vidfile): info = json.loads(stdout.decode()) meta['frames'] = int(info['streams'][0]['nb_read_packets']) d = float(info['format']['duration']) - meta['duration'] = d - meta['fps'] = round(meta['frames'] / d, 2) + meta['duration'] = max(d, 0.0001) + meta['fps'] = round(meta['frames'] / meta['duration'], 2) return meta, True else: eprint(0, cmd + '\n returned %d' % retval) @@ -1737,8 +1737,8 @@ def get_meta(vidfile): if m: meta['frames'] = int(m.group(1)) d = hms2s(m.group(2)) - meta['duration'] = d - meta['fps'] = round(meta['frames'] / d, 2) + meta['duration'] = max(d, 0.0001) + meta['fps'] = round(meta['frames'] / meta['duration'], 2) return meta, True else: eprint(0, cmd + '\n returned %d' % retval) -- 2.30.2