MCPcopy Index your code
hub / github.com/Breakthrough/PySceneDetect / test_detect_scenes_callback

Function test_detect_scenes_callback

tests/test_scene_manager.py:109–142  ·  view source on GitHub ↗

Test SceneManager detect_scenes method with a callback function. Note that the API signature of the callback will undergo breaking changes in v1.0.

(test_video_file)

Source from the content-addressed store, hash-verified

107
108
109def test_detect_scenes_callback(test_video_file):
110 """Test SceneManager detect_scenes method with a callback function.
111
112 Note that the API signature of the callback will undergo breaking changes in v1.0.
113 """
114 video = VideoStreamCv2(test_video_file)
115 sm = SceneManager()
116 sm.add_detector(ContentDetector())
117
118 fake_callback = FakeCallback()
119
120 video_fps = video.frame_rate
121 start_time = FrameTimecode("00:00:05", video_fps)
122 end_time = FrameTimecode("00:00:15", video_fps)
123 video.seek(start_time)
124 sm.auto_downscale = True
125
126 _ = sm.detect_scenes(
127 video=video, end_time=end_time, callback=fake_callback.get_callback_lambda()
128 )
129 scene_list = sm.get_scene_list()
130 assert [start for start, end in scene_list] == TEST_VIDEO_START_FRAMES_ACTUAL
131 assert fake_callback.scene_list == TEST_VIDEO_START_FRAMES_ACTUAL[1:]
132
133 # Perform same test using callback function instead of lambda.
134 sm.clear()
135 sm.add_detector(ContentDetector())
136 fake_callback = FakeCallback()
137 video.seek(start_time)
138
139 _ = sm.detect_scenes(video=video, end_time=end_time, callback=fake_callback.get_callback_func())
140 scene_list = sm.get_scene_list()
141 assert [start for start, end in scene_list] == TEST_VIDEO_START_FRAMES_ACTUAL
142 assert fake_callback.scene_list == TEST_VIDEO_START_FRAMES_ACTUAL[1:]
143
144
145def test_detect_scenes_callback_adaptive(test_video_file):

Callers

nothing calls this directly

Calls 12

add_detectorMethod · 0.95
seekMethod · 0.95
detect_scenesMethod · 0.95
get_callback_lambdaMethod · 0.95
get_scene_listMethod · 0.95
clearMethod · 0.95
get_callback_funcMethod · 0.95
VideoStreamCv2Class · 0.90
SceneManagerClass · 0.90
ContentDetectorClass · 0.90
FrameTimecodeClass · 0.90
FakeCallbackClass · 0.85

Tested by

no test coverage detected