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

Function test_vfr_scene_detection

tests/test_vfr.py:99–123  ·  view source on GitHub ↗

Scene detection on VFR video should produce timestamps matching known ground truth. Both PyAV (native PTS) and OpenCV (CAP_PROP_POS_MSEC) should agree on scene cuts since both expose accurate PTS-derived timestamps.

(test_vfr_video: str, backend: str)

Source from the content-addressed store, hash-verified

97
98@pytest.mark.parametrize("backend", ["pyav", "opencv"])
99def test_vfr_scene_detection(test_vfr_video: str, backend: str):
100 """Scene detection on VFR video should produce timestamps matching known ground truth.
101
102 Both PyAV (native PTS) and OpenCV (CAP_PROP_POS_MSEC) should agree on scene cuts since
103 both expose accurate PTS-derived timestamps.
104 """
105 video = open_video(test_vfr_video, backend=backend)
106 sm = SceneManager()
107 sm.add_detector(ContentDetector())
108 sm.detect_scenes(video=video, end_time=10.0)
109 scene_list = sm.get_scene_list()
110
111 # The last scene ends at the clip boundary which may vary by backend; only check known cuts.
112 assert len(scene_list) >= len(EXPECTED_SCENES_VFR), (
113 f"[{backend}] Expected at least {len(EXPECTED_SCENES_VFR)} scenes, got {len(scene_list)}"
114 )
115 for i, ((start, end), (exp_start_tc, exp_end_tc)) in enumerate(
116 zip(scene_list, EXPECTED_SCENES_VFR, strict=False)
117 ):
118 assert start.get_timecode() == exp_start_tc, (
119 f"[{backend}] Scene {i + 1} start: expected {exp_start_tc!r}, got {start.get_timecode()!r}"
120 )
121 assert end.get_timecode() == exp_end_tc, (
122 f"[{backend}] Scene {i + 1} end: expected {exp_end_tc!r}, got {end.get_timecode()!r}"
123 )
124
125
126def test_vfr_seek_pyav(test_vfr_video: str):

Callers

nothing calls this directly

Calls 7

add_detectorMethod · 0.95
detect_scenesMethod · 0.95
get_scene_listMethod · 0.95
open_videoFunction · 0.90
SceneManagerClass · 0.90
ContentDetectorClass · 0.90
get_timecodeMethod · 0.80

Tested by

no test coverage detected