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

Function test_save_images_singlethreaded

tests/test_output.py:134–168  ·  view source on GitHub ↗

Test scenedetect.scene_manager.save_images function.

(test_video_file, tmp_path: Path)

Source from the content-addressed store, hash-verified

132
133
134def test_save_images_singlethreaded(test_video_file, tmp_path: Path):
135 """Test scenedetect.scene_manager.save_images function."""
136 video = VideoStreamCv2(test_video_file)
137 sm = SceneManager()
138 sm.add_detector(ContentDetector())
139
140 image_name_glob = "scenedetect.tempfile.*.jpg"
141 image_name_template = (
142 "scenedetect.tempfile.$SCENE_NUMBER.$IMAGE_NUMBER.$FRAME_NUMBER.$TIMESTAMP_MS.$TIMECODE"
143 )
144
145 video_fps = video.frame_rate
146 scene_list = [
147 (FrameTimecode(start, video_fps), FrameTimecode(end, video_fps))
148 for start, end in [(0, 100), (200, 300), (300, 400)]
149 ]
150
151 image_filenames = save_images(
152 scene_list=scene_list,
153 output_dir=tmp_path,
154 video=video,
155 num_images=3,
156 image_extension="jpg",
157 image_name_template=image_name_template,
158 threading=True,
159 )
160
161 # Ensure images got created, and the proper number got created.
162 total_images = 0
163 for scene_number in image_filenames:
164 for path in image_filenames[scene_number]:
165 assert tmp_path.joinpath(path).exists(), f"expected {path} to exist"
166 total_images += 1
167
168 assert total_images == len([path for path in tmp_path.glob(image_name_glob)])
169
170
171@pytest.mark.parametrize("frame_margin", [1, 0.1, "0.1s", "00:00:00.100"])

Callers

nothing calls this directly

Calls 6

add_detectorMethod · 0.95
VideoStreamCv2Class · 0.90
SceneManagerClass · 0.90
ContentDetectorClass · 0.90
FrameTimecodeClass · 0.90
save_imagesFunction · 0.90

Tested by

no test coverage detected