Skip to content

Commit 12d3750

Browse files
authored
[bugfix] Fix progress bar accuracy for VFR videos (#562)
- Addresses progress bar behavior mentioned in Issue #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 #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.
2 parents fdd077a + 8a6029f commit 12d3750

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

scenedetect/scene_manager.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ def detect_scenes(
571571
)
572572
decode_thread.start()
573573
frame_im = None
574+
prev_position = None
574575

575576
logger.info("Detecting scenes...")
576577
try:
@@ -587,7 +588,13 @@ def detect_scenes(
587588
progress_bar.set_description(
588589
PROGRESS_BAR_DESCRIPTION % len(self._cutting_list), refresh=False
589590
)
590-
progress_bar.update(1 + frame_skip)
591+
# Increment progress bar by delta of position.frame_num instead of 1
592+
# to handle VFR video where frame count is an approximation.
593+
delta = (
594+
1 if prev_position is None else position.frame_num - prev_position.frame_num
595+
)
596+
progress_bar.update(delta)
597+
prev_position = position
591598
finally:
592599
if progress_bar is not None:
593600
progress_bar.set_description(

0 commit comments

Comments
 (0)