当前位置: 首页>>代码示例>>Python>>正文


Python SourceTrackObject.media_duration方法代码示例

本文整理汇总了Python中pitivi.timeline.track.SourceTrackObject.media_duration方法的典型用法代码示例。如果您正苦于以下问题:Python SourceTrackObject.media_duration方法的具体用法?Python SourceTrackObject.media_duration怎么用?Python SourceTrackObject.media_duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pitivi.timeline.track.SourceTrackObject的用法示例。


在下文中一共展示了SourceTrackObject.media_duration方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addClip

# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import media_duration [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)
开发者ID:bemasc,项目名称:pitivi,代码行数:12,代码来源:test_transitions.py

示例2: testUpdatesAfterEnablingUpdates

# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import media_duration [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")]))
开发者ID:bemasc,项目名称:pitivi,代码行数:98,代码来源:test_transitions.py

示例3: testAddRemoveTransitions

# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import media_duration [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")])
开发者ID:bemasc,项目名称:pitivi,代码行数:75,代码来源:test_transitions.py

示例4: testUpdateAfterAddingAndRemovingTrackObjects

# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import media_duration [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)
开发者ID:bemasc,项目名称:pitivi,代码行数:71,代码来源:test_transitions.py

示例5: testTransitionProperties

# 需要导入模块: from pitivi.timeline.track import SourceTrackObject [as 别名]
# 或者: from pitivi.timeline.track.SourceTrackObject import media_duration [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)
#.........这里部分代码省略.........
开发者ID:bemasc,项目名称:pitivi,代码行数:103,代码来源:test_transitions.py


注:本文中的pitivi.timeline.track.SourceTrackObject.media_duration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。