Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_prune_clips_after_transitions(self):
"""test a reduce that removes clips that follow transitions"""
md = {'test': 'bar'}
tr = otio.schema.Track(name='foo', metadata=md)
for i in range(5):
ind = str(i)
if i in (2, 3):
tr.append(otio.schema.Transition(name='should_be_pruned' + ind))
tr.append(otio.schema.Clip(name='cl' + ind, metadata=md))
def no_clips_after_transitions(prev, thing, __):
if (
isinstance(prev, otio.schema.Transition) or
isinstance(thing, otio.schema.Transition)
):
return None
return thing
result = otio.algorithms.filtered_with_sequence_context(
tr,
no_clips_after_transitions
)
# emptying the track of transitions and the clips they follow and
def test_transition(self):
trx = otio.schema.Transition()
self.check_against_baseline(trx, "empty_transition")
"Example Fade Out",
tracks=[track]
)
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(24.0, 24.0),
duration=otio.opentime.RationalTime(24.0, 24.0)
)
)
trans = otio.schema.Transition(
in_offset=otio.opentime.RationalTime(12.0, 24.0),
out_offset=otio.opentime.RationalTime(0.0, 24.0)
)
tl.tracks[0].extend([cl, trans])
result = otio.adapters.write_to_string(
tl,
adapter_name='cmx_3600',
style='nucoda'
)
expected = r'''TITLE: Example Fade Out
001 My_Clip V C 00:00:01:00 00:00:01:12 00:00:00:00 00:00:00:12
* FROM CLIP NAME: My Clip
* FROM FILE: /var/tmp/clip.001.exr
mr = otio.schema.ExternalReference(
available_range=avail_tr,
target_url="/var/tmp/test.mov"
)
cl = otio.schema.Clip(
name=name + "_pre",
media_reference=mr,
source_range=tr,
)
seq = otio.schema.Track()
seq.append(cl)
in_offset = rt
out_offset = rt_2
trx = otio.schema.Transition(
name="AtoB",
transition_type=otio.schema.TransitionTypes.SMPTE_Dissolve,
in_offset=in_offset,
out_offset=out_offset,
metadata={
"foo": "bar"
}
)
seq.append(trx)
cl_2 = copy.deepcopy(cl)
cl_2.name = name + "_post"
seq.append(copy.deepcopy(cl))
pre_duration = copy.deepcopy(seq[0].source_range.duration)
# print
name="V1",
children=[
otio.schema.Clip(
name="A",
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(
value=1,
rate=30
),
duration=otio.opentime.RationalTime(
value=50,
rate=30
)
)
),
otio.schema.Transition(
in_offset=otio.opentime.RationalTime(
value=7,
rate=30
),
out_offset=otio.opentime.RationalTime(
value=10,
rate=30
),
),
otio.schema.Clip(
name="B",
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(
value=100,
rate=30
),
def _otio_transition_from_clip(self, clip):
otio_transition = otio.schema.Transition(
name=self._get_name(clip),
transition_type=TRANSITION_MAP.get(
clip.attrib["asset-id"],
otio.schema.TransitionTypes.Custom))
self._add_properties_and_metadatas_to_otio(otio_transition, clip)
return otio_transition
def write_otio(otio_obj, to_session, track_kind=None):
WRITE_TYPE_MAP = {
otio.schema.Timeline: _write_timeline,
otio.schema.Stack: _write_stack,
otio.schema.Track: _write_track,
otio.schema.Clip: _write_item,
otio.schema.Gap: _write_item,
otio.schema.Transition: _write_transition,
otio.schema.SerializableCollection: _write_collection,
}
if type(otio_obj) in WRITE_TYPE_MAP:
return WRITE_TYPE_MAP[type(otio_obj)](otio_obj, to_session, track_kind)
raise NoMappingForOtioTypeError(
str(type(otio_obj)) + " on object: {}".format(otio_obj)
)
def create_rv_node_from_otio(otio_obj, track_kind=None):
WRITE_TYPE_MAP = {
otio.schema.Timeline: _create_timeline,
otio.schema.Stack: _create_stack,
otio.schema.Track: _create_track,
otio.schema.Clip: _create_item,
otio.schema.Gap: _create_item,
otio.schema.Transition: _create_transition,
otio.schema.SerializableCollection: _create_collection,
}
if type(otio_obj) in WRITE_TYPE_MAP:
return WRITE_TYPE_MAP[type(otio_obj)](otio_obj, track_kind)
raise NoMappingForOtioTypeError(
str(type(otio_obj)) + " on object: {}".format(otio_obj)
)