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

Function test_cli_time_scene_boundary

tests/test_cli.py:222–272  ·  view source on GitHub ↗

Validate frames that are processed when crossing a scene boundary. End time is the end frame to stop at, but with duration, we stop at start + duration - 1.

()

Source from the content-addressed store, hash-verified

220
221
222def test_cli_time_scene_boundary():
223 """Validate frames that are processed when crossing a scene boundary. End time is the end frame
224 to stop at, but with duration, we stop at start + duration - 1."""
225 # -------------------------------------------------------------------------------------
226 # | Scene | Frame | PTS | PTS + Duration | Annotation |
227 # -------------------------------------------------------------------------------------
228 # | 1 | 86 | 00:00:03.545 | 00:00:03.587 | Start Frame |
229 # | 1 | 87 | 00:00:03.587 | 00:00:03.629 | |
230 # | 1 | 88 | 00:00:03.629 | 00:00:03.670 | |
231 # | 1 | 89 | 00:00:03.670 | 00:00:03.712 | |
232 # | 1 | 90 | 00:00:03.712 | 00:00:03.754 | Scene 1 End |
233 # | 2 | 91 | 00:00:03.754 | 00:00:03.795 | Scene 2 Start |
234 # | 2 | 92 | 00:00:03.795 | 00:00:03.837 | |
235 # | 2 | 93 | 00:00:03.837 | 00:00:03.879 | |
236 # | 2 | 94 | 00:00:03.879 | 00:00:03.921 | |
237 # | 2 | 95 | 00:00:03.921 | 00:00:03.962 | |
238 # | 2 | 96 | 00:00:03.962 | 00:00:04.004 | End Frame |
239 # -------------------------------------------------------------------------------------
240 EXPECTED = """
241-----------------------------------------------------------------------
242 | Scene # | Start Frame | Start Time | End Frame | End Time |
243-----------------------------------------------------------------------
244 | 1 | 86 | 00:00:03.545 | 90 | 00:00:03.754 |
245 | 2 | 91 | 00:00:03.754 | 96 | 00:00:04.004 |
246-----------------------------------------------------------------------
247"""
248 # End time is the end frame to stop at, but with duration, we stop at start + duration - 1.
249 TEST_CASES = [
250 "time --start 86 --end 96",
251 "time --start 00:00:03.545 --end 00:00:04.004",
252 "time --start 3.545 --end 4.004",
253 "time --start 86 --duration 11",
254 "time --start 00:00:03.545 --duration 00:00:00.459",
255 "time --start 3.545 --duration 0.459",
256 ]
257 for test_case in TEST_CASES:
258 output = subprocess.check_output(
259 [
260 *SCENEDETECT_CMD.split(" "),
261 "-i",
262 DEFAULT_VIDEO_PATH,
263 "-m",
264 "0",
265 "detect-content",
266 "list-scenes",
267 "-n",
268 *test_case.split(),
269 ],
270 text=True,
271 )
272 assert EXPECTED in output, test_case
273
274
275def test_cli_time_end_of_video():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected