From 615e8330ccdce6630e4c5f34291f756a7bb66836 Mon Sep 17 00:00:00 2001 From: Geoff French Date: Wed, 10 Mar 2021 16:02:19 +0000 Subject: [PATCH] Fixed frame number generation in _gen_frames by using `round` to round to nearest rather than `int` to round down. --- pims/pyav_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pims/pyav_reader.py b/pims/pyav_reader.py index 220c7a16..2b453ee7 100644 --- a/pims/pyav_reader.py +++ b/pims/pyav_reader.py @@ -59,7 +59,7 @@ def _gen_frames(demuxer, time_base, frame_rate=1., first_pts=0): "Unable to read video: frames contain no timestamps. " "Please use PyAVReaderIndexed.") t = (timestamp - first_pts) * time_base - i = int(t * frame_rate) + i = int(round(t * frame_rate)) yield WrapPyAvFrame(frame, frame_no=i, metadata=dict(timestamp=timestamp, t=float(t)))