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

Function test_cli_save_fcp_fcpx

tests/test_cli.py:1329–1375  ·  view source on GitHub ↗

Test `save-fcp --format fcpx` produces a valid FCPXML 1.9 file.

(tmp_path: Path)

Source from the content-addressed store, hash-verified

1327
1328
1329def test_cli_save_fcp_fcpx(tmp_path: Path):
1330 """Test `save-fcp --format fcpx` produces a valid FCPXML 1.9 file."""
1331 from xml.etree import ElementTree
1332
1333 exit_code, _ = invoke_cli(
1334 [
1335 "-i",
1336 DEFAULT_VIDEO_PATH,
1337 "-o",
1338 str(tmp_path),
1339 "time",
1340 "-s",
1341 "2s",
1342 "-d",
1343 "4s",
1344 "detect-content",
1345 "save-fcp",
1346 ]
1347 )
1348 assert exit_code == 0
1349 output_path = tmp_path.joinpath(f"{DEFAULT_VIDEO_NAME}.xml")
1350 assert os.path.exists(output_path)
1351
1352 root = ElementTree.parse(output_path).getroot()
1353 assert root.tag == "fcpxml"
1354 assert root.attrib["version"] == "1.9"
1355
1356 # Format carries the rational frameDuration derived from the video's 24000/1001 fps.
1357 fmt = root.find("resources/format")
1358 assert fmt is not None
1359 assert fmt.attrib["frameDuration"] == "1001/24000s"
1360 assert fmt.attrib["width"] == "1280"
1361 assert fmt.attrib["height"] == "544"
1362
1363 # Asset references the source video via a file:// URI.
1364 media_rep = root.find("resources/asset/media-rep")
1365 assert media_rep is not None
1366 assert media_rep.attrib["src"].startswith("file://")
1367 assert media_rep.attrib["src"].endswith("goldeneye.mp4")
1368
1369 # Spine contains one `<asset-clip>` per scene (not wrapped in `<clip>`).
1370 asset_clips = root.findall("library/event/project/sequence/spine/asset-clip")
1371 assert len(asset_clips) == 2
1372 # All clip time attributes are rational strings ending in "s".
1373 for clip in asset_clips:
1374 for attr in ("offset", "start", "duration"):
1375 assert clip.attrib[attr].endswith("s")
1376
1377
1378def test_cli_save_fcp_fcp7(tmp_path: Path):

Callers

nothing calls this directly

Calls 1

invoke_cliFunction · 0.90

Tested by

no test coverage detected