-
Notifications
You must be signed in to change notification settings - Fork 510
[bugfix] Fix progress bar accuracy for VFR videos #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -571,6 +571,7 @@ def detect_scenes( | |
| ) | ||
| decode_thread.start() | ||
| frame_im = None | ||
| prev_position = None | ||
|
|
||
| logger.info("Detecting scenes...") | ||
| try: | ||
|
|
@@ -581,13 +582,22 @@ def detect_scenes( | |
| if next_frame is not None: | ||
| frame_im = next_frame | ||
| assert frame_im is not None | ||
| if prev_position is None: | ||
| prev_position = self._start_pos | ||
| assert prev_position is not None | ||
| new_cuts = self._process_frame(position, frame_im, callback) | ||
| if progress_bar is not None: | ||
| if new_cuts: | ||
| progress_bar.set_description( | ||
| PROGRESS_BAR_DESCRIPTION % len(self._cutting_list), refresh=False | ||
| ) | ||
| progress_bar.update(1 + frame_skip) | ||
| # Increment progress bar by delta of position.frame_num instead of 1 | ||
| # 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 | ||
| progress_bar.update((1 if is_first_frame else delta_pos) + frame_skip) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When The decode thread queues a frame, then skips, so consecutive queued positions differ by |
||
| prev_position = position | ||
| finally: | ||
| if progress_bar is not None: | ||
| progress_bar.set_description( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position.frame_num == 0won't hold when detection starts from a seek (e.g.start_timeis set) leading to an off by 1 error in some cases. Both this and theframe_skipissue below can be fixed if we keepprev_position = Noneand computing: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_poswhich is set on the decode thread.