當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。