Demonstrate how to use a callback with the SceneManager detect_scenes method.
(test_video_file: str)
| 119 | |
| 120 | |
| 121 | def test_api_scene_manager_callback(test_video_file: str): |
| 122 | """Demonstrate how to use a callback with the SceneManager detect_scenes method.""" |
| 123 | import numpy |
| 124 | |
| 125 | from scenedetect import ContentDetector, FrameTimecode, SceneManager, open_video |
| 126 | |
| 127 | # Callback to invoke on the first frame of every new scene detection. |
| 128 | def on_new_scene(frame_img: numpy.ndarray, position: FrameTimecode): |
| 129 | print(f"New scene found at frame {position.frame_num}.") |
| 130 | |
| 131 | video = open_video(test_video_file) |
| 132 | scene_manager = SceneManager() |
| 133 | scene_manager.add_detector(ContentDetector()) |
| 134 | scene_manager.detect_scenes(video=video, callback=on_new_scene) |
| 135 | |
| 136 | |
| 137 | def test_api_device_callback(test_video_file: str): |
nothing calls this directly
no test coverage detected