[bugfix] Fix progress bar accuracy for VFR videos - #562
Conversation
|
Hi @nathanmdan; just checking in, are you okay making the changes I asked for? |
|
Hi @Breakthrough, my apologies, but can you please show me where I might find your change requests? I'm afraid I don't see them. |
| # First frame increments by 1 as base case. | ||
| delta_pos = position.frame_num - prev_position.frame_num | ||
| is_first_frame = position.frame_num == 0 | ||
| progress_bar.update((1 if is_first_frame else delta_pos) + frame_skip) |
There was a problem hiding this comment.
When frame_skip > 0, the skipped frames are already reflected in position.frame_num. See the prev. comment for an alternative.
The decode thread queues a frame, then skips, so consecutive queued positions differ by frame_skip + 1). Adding + frame_skip on top double-counts them, e.g. with frame_skip=1 the bar advances 3 per processed frame instead of 2.
| # to handle VFR video where frame count is an approximation. | ||
| # First frame increments by 1 as base case. | ||
| delta_pos = position.frame_num - prev_position.frame_num | ||
| is_first_frame = position.frame_num == 0 |
There was a problem hiding this comment.
position.frame_num == 0 won't hold when detection starts from a seek (e.g. start_time is set) leading to an off by 1 error in some cases. Both this and the frame_skip issue below can be fixed if we keep prev_position = None and computing:
delta = 1 if prev_position is None else position.frame_num - prev_position.frame_num
progress_bar.update(delta)
prev_position = positionThe first frame counts as 1, and each later frame delta covers all of the skipped frames too (no special cases needed). This also avoids reading self._start_pos which is set on the decode thread.
|
Sorry about that - I thought they had already been published. My apologies for the mixup. You should see them now. |
|
No problem, I'll look into this! |
Addresses progress bar behavior mentioned in Issue Scene list has invalid end time for variable frame rate DVDs #561 where progress bar only goes up to ~80% with VFR videos, even with PyAV backend.
Progress bar now goes up to 100% for both PyAV and OpenCV backends.
Please note that this PR does not address the main topic of Issue Scene list has invalid end time for variable frame rate DVDs #561 (Invalid end time in scene lists for VFR videos) which was determined to be unique to the OpenCV backend and is not present when using PyAV.