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(
sq.range_of_child_at_index(2).duration,
otio.opentime.RationalTime(value=50, rate=24)
)
# should trim 5 frames off the front, and 5 frames off the back
sq_sourcerange = otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(5, 24),
duration=otio.opentime.RationalTime(140, 24),
)
sq.source_range = sq_sourcerange
self.assertEqual(
sq.trimmed_range_of_child_at_index(0),
otio.opentime.TimeRange(
otio.opentime.RationalTime(5, 24),
otio.opentime.RationalTime(45, 24)
)
)
self.assertEqual(
sq.trimmed_range_of_child_at_index(1),
sq.range_of_child_at_index(1)
)
self.assertEqual(
sq.trimmed_range_of_child_at_index(2),
otio.opentime.TimeRange(
otio.opentime.RationalTime(100, 24),
otio.opentime.RationalTime(45, 24),
)
)
# get the trimmed range in the parent
def test_long_running_timecode_24(self):
final_frame_number = 24 * 60 * 60 * 24 - 1
final_time = otio.opentime.from_frames(final_frame_number, 24)
self.assertEqual(
otio.opentime.to_timecode(final_time),
"23:59:59:23"
)
step_time = otio.opentime.RationalTime(value=1, rate=24)
# fetching this test function from the c++ module directly
cumulative_time = otio._opentime._testing.add_many(
step_time,
final_frame_number
)
self.assertEqual(cumulative_time, final_time)
# Adding by a non-multiple of 24
for fnum in range(1113, final_frame_number, 1113):
rt = otio.opentime.from_frames(fnum, 24)
tc = otio.opentime.to_timecode(rt)
rt2 = otio.opentime.from_timecode(tc, 24)
self.assertEqual(rt, rt2)
self.assertEqual(tc, otio.opentime.to_timecode(rt2))
list(
sq.each_clip(
otio.opentime.TimeRange(
otio.opentime.RationalTime(150, 24)
)
)
),
[]
)
self.assertEqual(
sq.transformed_time(otio.opentime.RationalTime(0, 24), clip1),
otio.opentime.RationalTime(100, 24)
)
self.assertEqual(
sq.transformed_time(otio.opentime.RationalTime(0, 24), clip2),
otio.opentime.RationalTime(51, 24)
)
self.assertEqual(
sq.transformed_time(otio.opentime.RationalTime(0, 24), clip3),
otio.opentime.RationalTime(2, 24)
)
self.assertEqual(
sq.transformed_time(otio.opentime.RationalTime(50, 24), clip1),
otio.opentime.RationalTime(150, 24)
)
self.assertEqual(
sq.transformed_time(otio.opentime.RationalTime(50, 24), clip2),
otio.opentime.RationalTime(101, 24)
)
self.assertEqual(
def test_iterating_over_dupes(self):
timeline = otio.schema.Timeline()
track = otio.schema.Track()
timeline.tracks.append(track)
clip = otio.schema.Clip(
name="Dupe",
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(10, 30),
duration=otio.opentime.RationalTime(15, 30)
)
)
# make several identical copies
for i in range(10):
dupe = copy.deepcopy(clip)
track.append(dupe)
self.assertEqual(len(track), 10)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 30),
duration=otio.opentime.RationalTime(150, 30)
),
track.trimmed_range()
)
def test_nucoda_edl_write_with_double_transition(self):
track = otio.schema.Track()
tl = otio.schema.Timeline("Double Transition", tracks=[track])
cl = otio.schema.Clip(
metadata={'cmx_3600': {'reel': 'Reel1'}},
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(24.0, 24.0),
duration=otio.opentime.RationalTime(24.0, 24.0)
)
)
trans = otio.schema.Transition(
in_offset=otio.opentime.RationalTime(6.0, 24.0),
out_offset=otio.opentime.RationalTime(6.0, 24.0)
)
cl2 = otio.schema.Clip(
metadata={'cmx_3600': {'reel': 'Reel2'}},
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(24.0, 24.0),
duration=otio.opentime.RationalTime(24.0, 24.0)
)
)
trans2 = otio.schema.Transition(
in_offset=otio.opentime.RationalTime(6.0, 24.0),
out_offset=otio.opentime.RationalTime(6.0, 24.0)
)
cl3 = otio.schema.Clip(
metadata={'cmx_3600': {'reel': 'Reel3'}},
source_range=otio.opentime.TimeRange(
def test_base_conversion(self):
# from a number
t = otio.opentime.RationalTime(10, 24)
with self.assertRaises(TypeError):
t.rescaled_to("foo")
self.assertEqual(t.rate, 24)
t = t.rescaled_to(48)
self.assertEqual(t.rate, 48)
# from another RationalTime
t = otio.opentime.RationalTime(10, 24)
t2 = otio.opentime.RationalTime(20, 48)
t = t.rescaled_to(t2)
self.assertEqual(t.rate, t2.rate)
start_time=opentime.RationalTime(1101071, 24),
duration=opentime.RationalTime(1055, 24)
)
self.assertTrue(clips[0].source_range == source_range)
available_range = opentime.TimeRange(
start_time=opentime.RationalTime(1101071, 24),
duration=opentime.RationalTime(1055, 24)
)
self.assertTrue(clips[0].available_range() == available_range)
clip_1_range = clips[1].available_range()
self.assertEqual(
clip_1_range,
opentime.TimeRange(
opentime.RationalTime(),
opentime.RationalTime(1, 24),
)
)
# Test serialization
tmp_path = tempfile.mkstemp(suffix=".xml", text=True)[1]
adapters.write_to_file(timeline, tmp_path)
# Similar to the test_roundtrip_disk2mem2disk above
# the track name element among others will not be present in a new xml.
with open(HIERO_XML_PATH, "r") as original_file:
with open(tmp_path, "r") as output_file:
self.assertNotEqual(original_file.read(), output_file.read())
def test_nucoda_edl_write_fade_in(self):
track = otio.schema.Track()
tl = otio.schema.Timeline(
"Example Fade In",
tracks=[track]
)
trans = otio.schema.Transition(
in_offset=otio.opentime.RationalTime(0.0, 24.0),
out_offset=otio.opentime.RationalTime(12.0, 24.0)
)
cl = otio.schema.Clip(
'My Clip',
metadata={'cmx_3600': {'reel': 'My_Clip'}},
media_reference=otio.schema.ExternalReference(
target_url="/var/tmp/clip.001.exr"
),
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(50.0, 24.0),
duration=otio.opentime.RationalTime(26.0, 24.0)
)
)
tl.tracks[0].extend([trans, cl])
result = otio.adapters.write_to_string(
def available_range(self):
if len(self) == 0:
return opentime.TimeRange()
duration = max(child.duration() for child in self)
return opentime.TimeRange(
opentime.RationalTime(0, duration.rate),
duration=duration
)
media_path
]
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = proc.communicate()
if proc.returncode != 0:
raise FFProbeFailedError(
"FFProbe Failed with error: {0}, output: {1}".format(
err, out
)
)
available_range = otio.opentime.TimeRange(
otio.opentime.RationalTime(0, 1).rescaled_to(fps),
otio.opentime.RationalTime(float(out), 1).rescaled_to(fps)
)
_MEDIA_RANGE_MAP[media_path] = available_range
return available_range