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


Python SourceTrackObject.getInterpolator方法代码示例

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


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

示例1: testSplitObjectKeyframes

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

示例2: testSplitObject

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


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