Test scenedetect.scene_manager.save_images guards against zero width scenes.
(test_video_file, tmp_path: Path)
| 202 | |
| 203 | # TODO: Test other functionality against zero width scenes. |
| 204 | def test_save_images_zero_width_scene(test_video_file, tmp_path: Path): |
| 205 | """Test scenedetect.scene_manager.save_images guards against zero width scenes.""" |
| 206 | video = VideoStreamCv2(test_video_file) |
| 207 | image_name_glob = "scenedetect.tempfile.*.jpg" |
| 208 | image_name_template = "scenedetect.tempfile.$SCENE_NUMBER.$IMAGE_NUMBER" |
| 209 | |
| 210 | video_fps = video.frame_rate |
| 211 | scene_list = [ |
| 212 | (FrameTimecode(start, video_fps), FrameTimecode(end, video_fps)) |
| 213 | for start, end in [(0, 0), (1, 1), (2, 3)] |
| 214 | ] |
| 215 | NUM_IMAGES = 10 |
| 216 | image_filenames = save_images( |
| 217 | scene_list=scene_list, |
| 218 | output_dir=tmp_path, |
| 219 | video=video, |
| 220 | num_images=10, |
| 221 | image_extension="jpg", |
| 222 | image_name_template=image_name_template, |
| 223 | ) |
| 224 | assert len(image_filenames) == 3 |
| 225 | assert all(len(image_filenames[scene]) == NUM_IMAGES for scene in image_filenames) |
| 226 | total_images = 0 |
| 227 | for scene_number in image_filenames: |
| 228 | for path in image_filenames[scene_number]: |
| 229 | assert tmp_path.joinpath(path).exists(), f"expected {path} to exist" |
| 230 | total_images += 1 |
| 231 | |
| 232 | assert total_images == len([path for path in tmp_path.glob(image_name_glob)]) |
| 233 | |
| 234 | |
| 235 | # |
nothing calls this directly
no test coverage detected