Skip to content

[bugfix] Fix progress bar accuracy for VFR videos - #562

Open
nathanmdan wants to merge 2 commits into
Breakthrough:mainfrom
nathanmdan:main
Open

[bugfix] Fix progress bar accuracy for VFR videos#562
nathanmdan wants to merge 2 commits into
Breakthrough:mainfrom
nathanmdan:main

Conversation

@nathanmdan

Copy link
Copy Markdown

@Breakthrough Breakthrough reopened this Aug 8, 2026
@Breakthrough

Copy link
Copy Markdown
Owner

Hi @nathanmdan; just checking in, are you okay making the changes I asked for?

@nathanmdan

nathanmdan commented Aug 16, 2026

Copy link
Copy Markdown
Author

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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = position

The 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.

@Breakthrough

Copy link
Copy Markdown
Owner

Sorry about that - I thought they had already been published. My apologies for the mixup. You should see them now.

@nathanmdan

Copy link
Copy Markdown
Author

No problem, I'll look into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants