* Fixed two instances of potential dividion by zero.
authorUrban Wallasch <urban.wallasch@freenet.de>
Wed, 26 May 2021 10:30:56 +0000 (12:30 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Wed, 26 May 2021 10:30:56 +0000 (12:30 +0200)
ffpreview.py

index bfcd24e6109710f004a918468814325bc097a369..eb7dbdbccc5391081de69fbfccfe47c06a743f14 100755 (executable)
@@ -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)