本文整理汇总了Python中pitivi.timeline.track.SourceTrackObject.start方法的典型用法代码示例。如果您正苦于以下问题:Python SourceTrackObject.start方法的具体用法?Python SourceTrackObject.start怎么用?Python SourceTrackObject.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitivi.timeline.track.SourceTrackObject
的用法示例。
在下文中一共展示了SourceTrackObject.start方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetPreviousTrackObject
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testGetPreviousTrackObject(self):
factory = self.factory
stream = self.stream
track1 = self.track1
obj1 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj1)
obj2 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj2)
obj3 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj3)
obj4 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj4)
obj1.start = 1 * gst.SECOND
obj1.duration = 5 * gst.SECOND
obj1.priority = 1
obj2.start = 8 * gst.SECOND
obj2.duration = 5 * gst.SECOND
obj2.priority = 1
obj3.start = 6 * gst.SECOND
obj3.duration = 5 * gst.SECOND
obj3.priority = 2
obj4.start = 7 * gst.SECOND
obj4.duration = 5 * gst.SECOND
obj4.priority = 3
# no previous object
self.failUnlessRaises(TrackError, track1.getPreviousTrackObject, obj4)
# same priority
prev = track1.getPreviousTrackObject(obj2)
self.failUnlessEqual(prev, obj1)
# given priority
prev = track1.getPreviousTrackObject(obj2, priority=2)
self.failUnlessEqual(prev, obj3)
# any priority
prev = track1.getPreviousTrackObject(obj2, priority=None)
self.failUnlessEqual(prev, obj4)
obj3.start = 8 * gst.SECOND
# same start
prev = track1.getPreviousTrackObject(obj2, priority=None)
self.failUnlessEqual(prev, obj3)
示例2: addClip
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def addClip(name, start, end):
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
obj.name = name
names[obj] = name
objs[name] = obj
track1.addTrackObject(obj)
示例3: configureStreams
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def configureStreams(self, inputs, offsets):
count = 0
for i in inputs:
factory = self.facs[i][0]
stream = self.facs[i][1]
track_object = SourceTrackObject(factory, stream)
self.track_objects.append(track_object)
track_object.start = offsets[count]
self.track.addTrackObject(track_object)
count += 1
示例4: testAudioOnly
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testAudioOnly(self):
audio_factory1 = AudioTestSourceFactory(3)
audio_factory1.duration = 10 * gst.SECOND
stream = AudioStream(gst.Caps('audio/x-raw-int'), 'src0')
audio_factory1.addOutputStream(stream)
timeline = Timeline()
track = Track(stream)
track_object1 = SourceTrackObject(audio_factory1, stream)
track_object1.start = 2 * gst.SECOND
track.addTrackObject(track_object1)
timeline.addTrack(track)
factory = TimelineSourceFactory(timeline)
bin = factory.makeBin()
self.failUnlessEqual(len(list(bin)), 1)
self.failUnlessEqual(factory.duration, 12 * gst.SECOND)
fakesink = gst.element_factory_make('fakesink')
def bin_pad_added_cb(bin, pad):
pad.link(fakesink.get_pad('sink'))
bin.connect('pad-added', bin_pad_added_cb)
def error_cb(bus, message):
gerror, debug = message.parse_error()
self.fail('%s: %s' % (gerror.message, debug))
def eos_cb(bus, message):
self.loop.quit()
pipeline = gst.Pipeline()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::error', error_cb)
bus.connect('message::eos', eos_cb)
pipeline.add(bin)
pipeline.add(fakesink)
pipeline.set_state(gst.STATE_PLAYING)
self.loop.run()
pipeline.set_state(gst.STATE_NULL)
factory.clean()
示例5: testGetTrackObjectsGroupedByLayer
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testGetTrackObjectsGroupedByLayer(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10, 0),
("b", 5, 15, 0),
("c", 20, 25, 0),
("d", 30, 35, 0),
("e", 30, 35, 2),
("f", 35, 45, 0),
("g", 40, 50, 0),
("h", 50, 60, 0),
("i", 55, 65, 1),
("j", 57, 60, 2),
("k", 62, 70, 3),
("l", 63, 67, 0),
]
expected = [
["a", "b", "c", "d", "f", "g", "h", "l"],
["i"],
["e", "j"],
["k"]
]
objs = {}
for name, start, end, priority in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.duration = end * gst.SECOND - obj.start
obj.priority = priority
track1.addTrackObject(obj)
objs[obj] = name
result = [[objs[obj] for obj in layer] for layer in
track1.getTrackObjectsGroupedByLayer()]
self.failUnlessEqual(result, expected)
示例6: testSplitObjectKeyframes
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testSplitObjectKeyframes(self):
DURATION = 10 * gst.SECOND
factory = AudioTestSourceFactory()
factory.duration = DURATION
stream_ = AudioStream(gst.Caps("audio/x-raw-int"))
obj = SourceTrackObject(factory, stream_)
track = Track(stream_)
track.addTrackObject(obj)
obj.start = 3 * gst.SECOND
obj.duration = DURATION
# create a three keyframes at: 3, 6 and 9 seconds
interpolator = obj.getInterpolator("volume")
keyframes = dict(((t * gst.SECOND, (t % 2, gst.INTERPOLATE_LINEAR))
for t in xrange(3, 10, 3)))
expected = []
expected2 = []
for time, (value, mode) in keyframes.iteritems():
kf = interpolator.newKeyframe(time, value, mode)
if time < (5 * gst.SECOND):
expected.append(kf)
else:
expected2.append(kf)
def getKeyframes(obj):
keyframes = obj.getInterpolator("volume").getInteriorKeyframes()
return list(keyframes)
obj2 = obj.splitObject(8 * gst.SECOND)
keyframes = getKeyframes(obj)
keyframes2 = getKeyframes(obj2)
self.failUnlessEqual(keyframes, expected)
self.failUnlessEqual(keyframes2, expected2)
示例7: testSplitObject
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testSplitObject(self):
DURATION = 10 * gst.SECOND
factory = AudioTestSourceFactory()
factory.duration = DURATION
stream_ = AudioStream(gst.Caps("audio/x-raw-int"))
obj = SourceTrackObject(factory, stream_)
track = Track(stream_)
track.addTrackObject(obj)
obj.start = 3 * gst.SECOND
obj.duration = DURATION
# create a zig-zag volume curve
interpolator = obj.getInterpolator("volume")
expected = dict(((t * gst.SECOND, (t % 2, gst.INTERPOLATE_LINEAR))
for t in xrange(3, 10, 3)))
for time, (value, mode) in expected.iteritems():
interpolator.newKeyframe(time, value, mode)
def getKeyframes(obj):
keyframes = obj.getInterpolator("volume").getInteriorKeyframes()
return dict(((kf.time, (kf.value, kf.mode)) for kf in keyframes))
monitor = TrackSignalMonitor(obj)
self.failUnlessRaises(TrackError, obj.splitObject, 2 * gst.SECOND)
self.failUnlessRaises(TrackError, obj.splitObject, 14 * gst.SECOND)
# should these be possible (ie create empty objects) ?
self.failUnlessRaises(TrackError, obj.splitObject, 3 * gst.SECOND)
self.failUnlessRaises(TrackError, obj.splitObject, 13 * gst.SECOND)
# splitObject at 4s should result in:
# obj (start 3, end 4) other1 (start 4, end 13)
other1 = obj.splitObject(4 * gst.SECOND)
self.failUnlessEqual(expected, getKeyframes(other1))
self.failUnlessEqual(obj.start, 3 * gst.SECOND)
self.failUnlessEqual(obj.in_point, 0 * gst.SECOND)
self.failUnlessEqual(obj.duration, 1 * gst.SECOND)
self.failUnlessEqual(obj.rate, 1)
self.failUnlessEqual(other1.start, 4 * gst.SECOND)
self.failUnlessEqual(other1.in_point, 1 * gst.SECOND)
self.failUnlessEqual(other1.duration, 9 * gst.SECOND)
self.failUnlessEqual(other1.rate, 1)
self.failUnlessEqual(monitor.start_changed_count, 0)
self.failUnlessEqual(monitor.duration_changed_count, 1)
# move other1 back to start = 1
other1.start = 1 * gst.SECOND
# splitObject again other1
monitor = TrackSignalMonitor(other1)
other2 = other1.splitObject(6 * gst.SECOND)
self.failUnlessEqual(other1.start, 1 * gst.SECOND)
self.failUnlessEqual(other1.in_point, 1 * gst.SECOND)
self.failUnlessEqual(other1.duration, 5 * gst.SECOND)
self.failUnlessEqual(other1.rate, 1)
self.failUnlessEqual(other2.start, 6 * gst.SECOND)
self.failUnlessEqual(other2.in_point, 6 * gst.SECOND)
self.failUnlessEqual(other2.duration, 4 * gst.SECOND)
self.failUnlessEqual(other2.rate, 1)
self.failUnlessEqual(monitor.start_changed_count, 0)
self.failUnlessEqual(monitor.duration_changed_count, 1)
示例8: testUpdatesAfterEnablingUpdates
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testUpdatesAfterEnablingUpdates(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 20, 25),
("d", 30, 35),
("e", 30, 35),
("f", 35, 45),
("g", 40, 50),
("h", 50, 60),
("i", 55, 65),
("j", 57, 60),
("k", 62, 70),
("l", 63, 67),
]
expected = [("a", "b"), ("d", "e"), ("f", "g")]
result = []
added = set()
removed = set()
def transitionAddedCb(track, transition):
pair =(names[transition.a], names[transition.b])
result.append(pair)
added.add(pair)
def transitionRemovedCb(track, transition):
pair = (names[transition.a], names[transition.b])
result.remove(pair)
removed.add(pair)
track1.connect("transition-added", transitionAddedCb)
track1.connect("transition-removed", transitionRemovedCb)
objs = {}
names = {}
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
names[obj] = name
objs[name] = obj
track1.addTrackObject(obj)
self.failUnlessEqual(result, expected)
track1.disableUpdates()
# move c so that it overlaps with b
# move g so that it overlaps d, e, f
# update the transitions, check that we have the expected
# configuration
test_data = [
("c", 12, 20),
("g", 30, 46),
]
expected = [("a", "b"), ("b", "c")]
added = set()
removed = set()
for name, start, end in test_data:
objs[name].start = start * gst.SECOND
objs[name].duration = (end - start) * gst.SECOND
track1.enableUpdates()
self.failUnlessEqual(result, expected)
# check that *only* (b, c) was added in the update
self.failUnlessEqual(added, set([("b", "c")]))
# check that *only* (d, e) was removed in the update
self.failUnlessEqual(removed, set([("d", "e"), ("f", "g")]))
# move c to a different layer. check that (b, c) transition is removed
track1.disableUpdates()
added = set()
removed = set()
objs["c"].priority = 1
expected = [("a", "b")]
track1.enableUpdates()
self.failUnlessEqual(result, expected)
self.failUnlessEqual(added, set())
self.failUnlessEqual(removed, set([("b", "c")]))
示例9: testUpdateAfterAddingAndRemovingTrackObjects
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testUpdateAfterAddingAndRemovingTrackObjects(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 20, 25),
("d", 30, 35),
("f", 35, 45),
("g", 40, 50),
("e", 30, 35),
("h", 50, 60),
("i", 55, 65),
("j", 57, 60),
("k", 62, 70),
("l", 63, 67),
]
# object j makes track arrangment invalid
valid_in_order = [True for x in "abcdefghi"]
valid_in_order.extend([False, False, False])
added_in_order = [("a", "b"), ("f", "g"), ("d", "e"),
("h", "i"), ("i", "k"), ("h", "i")]
removed_in_order = [("h", "i"), ("i", "k")]
objs = {}
names = {}
added = []
removed = []
def transitionAddedCb(track, transition):
added.append((names[transition.a],
names[transition.b]))
def transitionRemovedCb(track, transition):
removed.append((names[transition.a],
names[transition.b]))
track1.connect("transition-added", transitionAddedCb)
track1.connect("transition-removed", transitionRemovedCb)
valid = []
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
names[obj] = name
objs[name] = obj
track1.addTrackObject(obj)
valid.append(track1.valid_arrangement)
# removing this object brings (h, i) back
track1.removeTrackObject(objs["j"])
self.failUnlessEqual(added, added_in_order)
self.failUnlessEqual(removed, removed_in_order)
self.failUnlessEqual(valid, valid_in_order)
# removing this should make the track valid again
track1.removeTrackObject(objs["l"])
self.failUnlessEqual(track1.valid_arrangement,
True)
示例10: testAddRemoveTransitions
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testAddRemoveTransitions(self):
factory = self.factory
track1 = self.track1
track1._update_transitions = False
stream = self.stream
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 15, 20),
("d", 30, 35),
("e", 30, 35),
]
transitions = [
("a", "b"),
("d", "e"),
]
objs = {}
names = {}
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
track1.addTrackObject(obj)
names[obj] = name
objs[name] = obj
result = []
transition_objects = {}
def addTransition(b, c):
tr = Transition(objs[b], objs[c])
track1.addTransition(tr)
def transitionAddedCb(track, transition):
values =(names[transition.a], names[transition.b])
result.append(values)
transition_objects[values] = transition
def transitionRemovedCb(track, transition):
values =(names[transition.a], names[transition.b])
result.remove(values)
track1.connect("transition-added", transitionAddedCb)
track1.connect("transition-removed", transitionRemovedCb)
# add transitions and check that initial properties are properly
# evaluated
for a, b in transitions:
addTransition(a, b)
self.failUnlessEqual(result, transitions)
# check that adding a transition with a bogus track object raises an
# error
track1.removeTrackObject(objs["c"])
self.failUnlessRaises(TrackError, addTransition, "b", "c")
# check that adding a transition that already exists raises an error
self.failUnlessRaises(TrackError, addTransition, "d", "e")
# check that removing a transition directly works
track1.removeTransition(transition_objects["d", "e"])
self.failUnlessEqual(result, [("a", "b")])
# check tht we can restore a transition after deleting it
addTransition("d", "e")
self.failUnlessEqual(result, [("a", "b"), ("d", "e")])
示例11: testGetValidTransitionSlots
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testGetValidTransitionSlots(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 20, 25),
("d", 30, 35),
("e", 30, 35),
("f", 35, 45),
("g", 40, 50),
("h", 50, 60),
("i", 55, 65),
("j", 57, 60),
("k", 62, 70),
("l", 63, 67),
]
expected = [["a", "b"], ["d", "e"], ["f", "g"]]
objs = {}
names = {}
ordered = []
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.duration = end * gst.SECOND - obj.start
track1.addTrackObject(obj)
objs[name] = obj
names[obj] = name
ordered.append(obj)
slots, valid = track1.getValidTransitionSlots(ordered)
result = [[names[obj] for obj in layer] for layer in
slots]
self.failUnlessEqual(result, expected)
self.failUnlessEqual(track1.valid_arrangement, False)
test_data = [
("a", 0, 5),
("b", 9, 12),
("c", 8, 13)
]
ordered = []
for name, start, end in test_data:
ordered.append(objs[name])
objs[name].start = gst.SECOND * start
objs[name].duration = gst.SECOND * (end - start)
slots, valid = track1.getValidTransitionSlots(ordered)
self.failUnlessEqual(valid, False)
test_data = [
("a", 0, 5),
("b", 1, 4),
("c", 8, 13),
]
ordered = []
for name, start, end in test_data:
ordered.append(objs[name])
objs[name].start = gst.SECOND * start
objs[name].duration = gst.SECOND * (end - start)
slots, valid = track1.getValidTransitionSlots(ordered)
self.failUnlessEqual(valid, False)
示例12: testTransitionProperties
# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import start [as 别名]
def testTransitionProperties(self):
factory = self.factory
track1 = self.track1
track1._update_transitions = False
stream = self.stream
test_data = [
("a", 0, 10),
("b", 5, 15),
]
objs = {}
names = {}
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
track1.addTrackObject(obj)
names[obj] = name
objs[name] = obj
# add transitions and check that initial properties are properly
# evaluated
at = AudioTransition(objs["a"], objs["b"])
vt = VideoTransition(objs["a"], objs["b"])
# move a and b together,
# check that transition start, duration are updated
objs["a"].start = 5 * gst.SECOND
objs["b"].start = 10 * gst.SECOND
self.failUnlessEqual(vt.start, 10 * gst.SECOND)
self.failUnlessEqual(vt.duration, 5 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.start, 10 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.duration, 5 * gst.SECOND)
self.failUnlessEqual(at.start, 10 * gst.SECOND)
self.failUnlessEqual(at.duration, 5 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.start, 10 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.duration, 5 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.start, 10 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.duration, 5 * gst.SECOND)
# make A longer
objs["a"].duration = 11 * gst.SECOND
self.failUnlessEqual(vt.start, 10 * gst.SECOND)
self.failUnlessEqual(vt.duration, 6 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.start, 10 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.duration, 6 * gst.SECOND)
self.failUnlessEqual(at.start, 10 * gst.SECOND)
self.failUnlessEqual(at.duration, 6 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.start, 10 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.duration, 6 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.start, 10 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.duration, 6 * gst.SECOND)
# move B earlier
objs["b"].start = 9 * gst.SECOND
self.failUnlessEqual(vt.start, 9 * gst.SECOND)
self.failUnlessEqual(vt.duration, 7 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.start, 9 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.duration, 7 * gst.SECOND)
self.failUnlessEqual(vt.operation.props.media_duration, 7 * gst.SECOND)
self.failUnlessEqual(at.start, 9 * gst.SECOND)
self.failUnlessEqual(at.duration, 7 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.start, 9 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.duration, 7 * gst.SECOND)
self.failUnlessEqual(at.a_operation.props.media_duration, 7 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.start, 9 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.duration, 7 * gst.SECOND)
self.failUnlessEqual(at.b_operation.props.media_duration, 7 * gst.SECOND)
# check priority is currently zero
self.failUnlessEqual(vt.priority, 0)
# check video transition priority basic properties
self.failUnlessEqual(vt.operation.props.priority, 1)
vt.a.priority = 2
vt.b.priority = 2
self.failUnlessEqual(vt.priority, 2)
self.failUnlessEqual(vt.operation.props.priority, 7)
self.failUnlessEqual(at.priority, 2)
# check controller for even - odd stagger
vt.a.updatePosition(0)
vt.b.updatePosition(1)
self.failUnlessEqual(vt.a.gnl_object.props.priority, 9)
self.failUnlessEqual(at.a._stagger, 0)
self.failUnlessEqual(at.b._stagger, 1)
#.........这里部分代码省略.........