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

Function test_api_scene_manager_callback

tests/test_api.py:121–134  ·  view source on GitHub ↗

Demonstrate how to use a callback with the SceneManager detect_scenes method.

(test_video_file: str)

Source from the content-addressed store, hash-verified

119
120
121def 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
137def test_api_device_callback(test_video_file: str):

Callers

nothing calls this directly

Calls 5

add_detectorMethod · 0.95
detect_scenesMethod · 0.95
open_videoFunction · 0.90
SceneManagerClass · 0.90
ContentDetectorClass · 0.90

Tested by

no test coverage detected