Skip to content

Commit

Permalink
FCPXML: Added audition metadata extraction unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed May 2, 2024
1 parent 044acac commit 4fbf394
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class FinalCutPro_FCPXML_AuditionMarkers3: FCPXMLTestCase {
XCTAssertEqual(sequence.tcStartAsTimecode(), Self.tc("00:00:00:00", .fps23_976))
XCTAssertEqual(sequence.tcStartAsTimecode()?.frameRate, .fps23_976)
XCTAssertEqual(sequence.tcStartAsTimecode()?.subFramesBase, .max80SubFrames)
XCTAssertEqual(sequence.durationAsTimecode(), Self.tc("00:03:42:20", .fps23_976))
XCTAssertEqual(sequence.durationAsTimecode(), Self.tc("00:00:59:17", .fps23_976))
XCTAssertEqual(sequence.audioLayout, .stereo)
XCTAssertEqual(sequence.audioRate, .rate48kHz)

Expand Down Expand Up @@ -162,6 +162,68 @@ final class FinalCutPro_FCPXML_AuditionMarkers3: FCPXMLTestCase {
XCTAssertEqual(marker2.name, "Audition 3") // just to identify marker
XCTAssertEqual(marker2.timecode(), Self.tc("00:00:54:14", .fps23_976))
}

/// Test metadata that applies to marker(s).
func testExtractMarkersMetadata_MainTimeline() async throws {
// load file
let rawData = try fileContents

// load
let fcpxml = try FinalCutPro.FCPXML(fileContent: rawData)

// project
let project = try XCTUnwrap(fcpxml.allProjects().first)

let extractedMarkers = await project
.extract(preset: .markers, scope: .mainTimeline)
.sortedByAbsoluteStartTimecode()
// .zeroIndexed // not necessary after sorting - sort returns new array

let markers = extractedMarkers

let expectedMarkerCount = 4
XCTAssertEqual(markers.count, expectedMarkerCount)

print("Markers sorted by absolute timecode:")
print(Self.debugString(for: markers))

// markers

func md(
in mdtm: [FinalCutPro.FCPXML.Metadata.Metadatum],
key: FinalCutPro.FCPXML.Metadata.Key
) -> FinalCutPro.FCPXML.Metadata.Metadatum? {
let matches = mdtm.filter { $0.key == key }
XCTAssertLessThan(matches.count, 2)
return matches.first
}

// skip testing marker 1, it's not on an audition clip

// marker 2
do {
let marker = try XCTUnwrap(markers[safe: 1])
let mtdm = marker.value(forContext: .metadata)
XCTAssertEqual(mtdm.count, 11)

XCTAssertEqual(marker.name, "Audition 1")

// metadata from active audition clip
XCTAssertEqual(md(in: mtdm, key: .reel)?.value, "TestVideo2 Reel")
XCTAssertEqual(md(in: mtdm, key: .scene)?.value, "TestVideo2 Scene")
XCTAssertEqual(md(in: mtdm, key: .take)?.value, "TestVideo2 Take")
XCTAssertEqual(md(in: mtdm, key: .cameraAngle)?.value, "TestVideo2 Camera Angle")

// metadata from active clip's resource
XCTAssertEqual(md(in: mtdm, key: .rawToLogConversion)?.value, "0")
XCTAssertEqual(md(in: mtdm, key: .colorProfile)?.value, "HD (1-1-1)")
XCTAssertEqual(md(in: mtdm, key: .cameraISO)?.value, "0")
XCTAssertEqual(md(in: mtdm, key: .cameraColorTemperature)?.value, "0")
XCTAssertEqual(md(in: mtdm, key: .codecs)?.valueArray, ["'avc1'", "MPEG-4 AAC"])
XCTAssertEqual(md(in: mtdm, key: .ingestDate)?.value, "2023-11-22 04:01:31 -0800")
XCTAssertEqual(md(in: mtdm, key: .cameraName)?.value, "TestVideo2 Camera Name")
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<asset id="r6" name="TestVideo2" uid="53308E84E2E696489DF41ECEFBB51E41" start="0s" duration="142040/1000s" hasVideo="1" format="r7" hasAudio="1" videoSources="1" audioSources="1" audioChannels="2" audioRate="44100">
<media-rep kind="original-media" sig="53308E84E2E696489DF41ECEFBB51E41" src="file:///Users/user/Movies/TestVideo2.mp4"/>
<metadata>
<md key="com.apple.proapps.mio.cameraName" value="TestVideo2 Camera Name"/>
<md key="com.apple.proapps.studio.rawToLogConversion" value="0"/>
<md key="com.apple.proapps.spotlight.kMDItemProfileName" value="HD (1-1-1)"/>
<md key="com.apple.proapps.studio.cameraISO" value="0"/>
Expand All @@ -44,7 +45,7 @@
<library location="file:///Users/user/Movies/FCPXMLTest.fcpbundle/">
<event name="Test Event" uid="8A2EE1B4-CD4D-4D7E-8964-4CB0BA973669">
<project name="Test Project" uid="875AE696-C2E5-4E42-AFC3-D2A2EEA7ABDF" modDate="2023-12-24 16:21:00 -0800">
<sequence format="r1" duration="80300220/360000s" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<sequence format="r1" duration="1434433/24000s" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<transition name="Cross Dissolve" offset="0s" duration="286286/24000s">
<filter-video ref="r2" name="Cross Dissolve">
Expand All @@ -62,11 +63,17 @@
<marker start="199199/12000s" duration="1001/24000s" value="Shot_01" completed="0"/>
</asset-clip>
<audition offset="760760/24000s">
<asset-clip ref="r6" name="TestVideo2" duration="646646/24000s" format="r7" tcFormat="NDF" audioRole="dialogue">
<asset-clip ref="r6" name="TestVideo2" duration="673673/24000s" format="r7" tcFormat="NDF" audioRole="dialogue">
<conform-rate srcFrameRate="25"/>
<marker start="177/25s" duration="1001/24000s" value="Audition 1"/>
<marker start="344/25s" duration="1001/24000s" value="Audition 2"/>
<marker start="22s" duration="1001/24000s" value="Audition 3"/>
<metadata>
<md key="com.apple.proapps.studio.reel" value="TestVideo2 Reel"/>
<md key="com.apple.proapps.studio.scene" value="TestVideo2 Scene"/>
<md key="com.apple.proapps.studio.shot" value="TestVideo2 Take"/>
<md key="com.apple.proapps.studio.angle" value="TestVideo2 Camera Angle"/>
</metadata>
</asset-clip>
<asset-clip ref="r4" name="TestVideo" start="1186185/24000s" duration="901901/24000s" format="r5" tcFormat="NDF" audioRole="dialogue">
<adjust-colorConform enabled="1" autoOrManual="manual" conformType="conformNone" peakNitsOfPQSource="1000" peakNitsOfSDRToPQSource="203"/>
Expand Down

0 comments on commit 4fbf394

Please sign in to comment.