Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertEqual(
marker.marked_range.start_time,
otio.opentime.from_timecode("01:00:01:14", fps)
)
self.assertEqual(marker.color, otio.schema.MarkerColor.RED)
unnamed_marker = timeline.tracks[0][6].markers[0]
self.assertEqual(unnamed_marker.name, '')
self.assertEqual(
timeline.tracks[0][4].name,
"ZZ100_504B (LAY1)"
)
self.assertEqual(
timeline.tracks[0][4].source_range.duration,
otio.opentime.from_timecode("00:00:04:05", fps)
)
self.assertEqual(
timeline.tracks[0][5].name,
"ZZ100_507C (LAY2)"
)
self.assertEqual(
timeline.tracks[0][5].source_range.duration,
otio.opentime.from_timecode("00:00:06:17", fps)
)
self.assertEqual(
timeline.tracks[0][6].name,
"ZZ100_508 (LAY2)"
)
self.assertEqual(
timeline.tracks[0][6].source_range.duration,
otio.opentime.from_timecode("00:00:07:02", fps)
)
self.assertEqual(
timeline.tracks[0][1].name,
"ZZ100_502A (LAY3)"
)
self.assertEqual(
timeline.tracks[0][1].source_range.duration,
otio.opentime.from_timecode("00:00:02:02", fps)
)
self.assertEqual(
timeline.tracks[0][2].name,
"ZZ100_503A (LAY1)"
)
self.assertEqual(
timeline.tracks[0][2].source_range.duration,
otio.opentime.from_timecode("00:00:01:04", fps)
)
self.assertEqual(
timeline.tracks[0][3].name,
"ZZ100_504C (LAY1)"
)
self.assertEqual(
timeline.tracks[0][3].source_range.duration,
otio.opentime.from_timecode("00:00:04:19", fps)
)
self.assertEqual(len(timeline.tracks[0][3].markers), 1)
marker = timeline.tracks[0][3].markers[0]
self.assertEqual(marker.name, "ANIM FIX NEEDED")
self.assertEqual(marker.metadata.get("cmx_3600").get("color"), "RED")
self.assertEqual(
marker.marked_range.start_time,
self.assertEqual(
clip.duration(),
otio.opentime.from_timecode("00:00:01:12", 24)
)
# TODO: We should be able to ask for the source without the effect
# self.assertEqual(
# clip.source_range,
# otio.opentime.TimeRange(
# start_time=otio.opentime.from_timecode("01:00:06:00", 24),
# duration=otio.opentime.from_timecode("00:00:02:22", 24)
# )
# )
self.assertEqual(
clip.range_in_parent(),
otio.opentime.TimeRange(
start_time=otio.opentime.from_timecode("00:11:31:16", 24),
duration=otio.opentime.from_timecode("00:00:01:12", 24)
)
def test_timecode_23976_fps(self):
# This should behave exactly like 24 fps
timecode = "00:00:01:00"
t = otio.opentime.RationalTime(value=24, rate=23.976)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 23.976))
timecode = "00:01:00:00"
t = otio.opentime.RationalTime(value=24 * 60, rate=23.976)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 23.976))
timecode = "01:00:00:00"
t = otio.opentime.RationalTime(value=24 * 60 * 60, rate=23.976)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 23.976))
timecode = "24:00:00:00"
t = otio.opentime.RationalTime(value=24 * 60 * 60 * 24, rate=23.976)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 23.976))
timecode = "23:59:59:23"
t = otio.opentime.RationalTime(
value=24 * 60 * 60 * 24 - 1,
rate=(24000 / 1001.0)
)
self.assertEqual(
t, otio.opentime.from_timecode(timecode, (24000 / 1001.0))
def test_timecode_24(self):
timecode = "00:00:01:00"
t = otio.opentime.RationalTime(value=24, rate=24)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 24))
timecode = "00:01:00:00"
t = otio.opentime.RationalTime(value=24 * 60, rate=24)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 24))
timecode = "01:00:00:00"
t = otio.opentime.RationalTime(value=24 * 60 * 60, rate=24)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 24))
timecode = "24:00:00:00"
t = otio.opentime.RationalTime(value=24 * 60 * 60 * 24, rate=24)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 24))
timecode = "23:59:59:23"
t = otio.opentime.RationalTime(value=24 * 60 * 60 * 24 - 1, rate=24)
self.assertEqual(t, otio.opentime.from_timecode(timecode, 24))
def test_invalid_record_timecode(self):
with self.assertRaises(ValueError):
tl = otio.adapters.read_from_file(TIMECODE_MISMATCH_TEST)
with self.assertRaises(cmx_3600.EDLParseError):
tl = otio.adapters.read_from_file(TIMECODE_MISMATCH_TEST, rate=25)
tl = otio.adapters.read_from_file(
TIMECODE_MISMATCH_TEST,
rate=25,
ignore_timecode_mismatch=True
)
self.assertEqual(
tl.tracks[0][3].range_in_parent(),
otio.opentime.TimeRange(
start_time=otio.opentime.from_timecode("00:00:17:22", 25),
duration=otio.opentime.from_timecode("00:00:01:24", 25)
)
def test_cdl_read(self):
edl_path = CDL_EXAMPLE_PATH
timeline = otio.adapters.read_from_file(edl_path)
self.assertTrue(timeline is not None)
self.assertEqual(len(timeline.tracks), 1)
self.assertEqual(len(timeline.tracks[0]), 2)
for clip in timeline.tracks[0]:
# clip = timeline.tracks[0][0]
self.assertEqual(
clip.name,
"ZZ100_501 (LAY3)"
)
self.assertEqual(
clip.source_range.duration,
otio.opentime.from_timecode("00:00:01:07", 24)
)
cdl = clip.metadata.get("cdl", {})
self.assertEqual(
cdl.get("asc_sat"),
0.9
)
self.assertEqual(
list(cdl.get("asc_sop").get("slope")),
[0.1, 0.2, 0.3]
)
self.assertEqual(
list(cdl.get("asc_sop").get("offset")),
[1.0000, -0.0122, 0.0305]
)
self.assertEqual(
list(cdl.get("asc_sop").get("power")),
def test_time_timecode_convert(self):
timecode = "00:06:56:17"
t = otio.opentime.from_timecode(timecode, 24)
self.assertEqual(timecode, otio.opentime.to_timecode(t))
# When looking for Start, Duration and End, they might be missing
# or blank. Treat None and "" as the same via: get(k,"")!=""
# To have a valid source range, you need Start and either Duration
# or End. If all three are provided, we check to make sure they match.
if metadata.get("Start", "") != "":
value = metadata.pop("Start")
try:
start = otio.opentime.from_timecode(value, fps)
except (ValueError, TypeError):
raise ALEParseError("Invalid Start timecode: {}".format(value))
duration = None
end = None
if metadata.get("Duration", "") != "":
value = metadata.pop("Duration")
try:
duration = otio.opentime.from_timecode(value, fps)
except (ValueError, TypeError):
raise ALEParseError("Invalid Duration timecode: {}".format(
value
))
if metadata.get("End", "") != "":
value = metadata.pop("End")
try:
end = otio.opentime.from_timecode(value, fps)
except (ValueError, TypeError):
raise ALEParseError("Invalid End timecode: {}".format(
value
))
if duration is None:
duration = end - start
if end is None:
end = start + duration
# Gather all the columns into a dictionary
# For expected columns, like Name, Start, etc. we will pop (remove)
# those from metadata, leaving the rest alone.
metadata = dict(zip(columns, row))
clip = otio.schema.Clip()
clip.name = metadata.pop("Name", None)
# When looking for Start, Duration and End, they might be missing
# or blank. Treat None and "" as the same via: get(k,"")!=""
# To have a valid source range, you need Start and either Duration
# or End. If all three are provided, we check to make sure they match.
if metadata.get("Start", "") != "":
value = metadata.pop("Start")
try:
start = otio.opentime.from_timecode(value, fps)
except (ValueError, TypeError):
raise ALEParseError("Invalid Start timecode: {}".format(value))
duration = None
end = None
if metadata.get("Duration", "") != "":
value = metadata.pop("Duration")
try:
duration = otio.opentime.from_timecode(value, fps)
except (ValueError, TypeError):
raise ALEParseError("Invalid Duration timecode: {}".format(
value
))
if metadata.get("End", "") != "":
value = metadata.pop("End")
try:
end = otio.opentime.from_timecode(value, fps)