MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / test_scene_list

Function test_scene_list

tests/test_scene_manager.py:28–61  ·  view source on GitHub ↗

Test SceneManager get_scene_list method with VideoStreamCv2/ContentDetector.

(test_video_file)

Source from the content-addressed store, hash-verified

26
27
28def test_scene_list(test_video_file):
29 """Test SceneManager get_scene_list method with VideoStreamCv2/ContentDetector."""
30 video = VideoStreamCv2(test_video_file)
31 sm = SceneManager()
32 sm.add_detector(ContentDetector())
33
34 video_fps = video.frame_rate
35 start_time = FrameTimecode("00:00:05", video_fps)
36 end_time = FrameTimecode("00:00:10", video_fps)
37
38 assert end_time.frame_num > start_time.frame_num
39
40 video.seek(start_time)
41 sm.auto_downscale = True
42
43 num_frames = sm.detect_scenes(video=video, end_time=end_time)
44
45 assert num_frames == (end_time.frame_num - start_time.frame_num)
46
47 scene_list = sm.get_scene_list()
48 assert scene_list
49 # Each scene is in the format (Start Timecode, End Timecode)
50 assert len(scene_list[0]) == 2
51
52 # First scene should start at start_time and last scene should end at end_time.
53 assert scene_list[0][0] == start_time
54 assert scene_list[-1][1] == end_time
55
56 for i, _ in enumerate(scene_list):
57 assert scene_list[i][0].frame_num < scene_list[i][1].frame_num
58 if i > 0:
59 # Ensure frame list is sorted (i.e. end time frame of
60 # one scene is equal to the start time of the next).
61 assert scene_list[i - 1][1] == scene_list[i][0]
62
63
64def test_get_scene_list_start_in_scene(test_video_file):

Callers

nothing calls this directly

Calls 8

add_detectorMethod · 0.95
seekMethod · 0.95
detect_scenesMethod · 0.95
get_scene_listMethod · 0.95
VideoStreamCv2Class · 0.90
SceneManagerClass · 0.90
ContentDetectorClass · 0.90
FrameTimecodeClass · 0.90

Tested by

no test coverage detected