Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions scenedetect/video_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,18 @@ def read(self):
if not self._started:
raise VideoDecoderNotStarted()

read_frame = False
if self._curr_cap is not None and self._end_of_video != True:
while not read_frame:
read_frame, self._last_frame = self._curr_cap.read()

# Switch to the next capture when the current one is over
if not read_frame and self._get_next_cap():
read_frame, self._last_frame = self._curr_cap.read()
if not read_frame and not self._get_next_cap():
break
if self._downscale_factor > 1:
self._last_frame = self._last_frame[
::self._downscale_factor, ::self._downscale_factor, :]

# Downscale frame if there was any
if read_frame and self._downscale_factor > 1:
self._last_frame = self._last_frame[
::self._downscale_factor, ::self._downscale_factor, :]

if self._end_time is not None and self._curr_time > self._end_time:
read_frame = False
self._last_frame = None
Expand Down
16 changes: 16 additions & 0 deletions tests/test_video_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import pytest
import cv2

from scenedetect.scene_manager import SceneManager
# PySceneDetect Library Imports
from scenedetect.video_manager import VideoManager
from scenedetect.video_manager import VideoOpenFailure
Expand Down Expand Up @@ -281,3 +282,18 @@ def test_multiple_videos(test_video_file):
# Will release the VideoManagers in vm_list as well.
video_manager.release()

def test_many_videos_downscale_detect_scenes(test_video_file):
""" Test scene detection on multiple videos in VideoManager. """

NUM_VIDEOS = 3
# Open VideoManager with NUM_VIDEOS test videos
video_manager = VideoManager([test_video_file] * NUM_VIDEOS)
video_manager.set_downscale_factor()

try:
video_manager.start()
scene_manager = SceneManager()
scene_manager.detect_scenes(frame_source=video_manager)
finally:
# Will release the VideoManagers in vm_list as well.
video_manager.release()