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


Python track.Track类代码示例

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


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

示例1: testSaveTimeline

    def testSaveTimeline(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()
        source1.addOutputStream(video_stream)

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        element = self.formatter._saveTimeline(timeline)
        self.failUnlessEqual(element.tag, "timeline")
        tracks = element.find("tracks")
        self.failUnlessEqual(len(tracks), 1)
开发者ID:superdump,项目名称:pitivi,代码行数:31,代码来源:test_etree_formatter.py

示例2: testSaveTrackEffect

    def testSaveTrackEffect(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))

        effect1 = EffectFactory('identity', 'identity')
        effect1.addOutputStream(video_stream)
        effect1.addInputStream(video_stream)

        #It is necessary to had the identity factory to the
        #effect_factories_dictionnary
        self.formatter.avalaible_effects._effect_factories_dict['identity'] =\
                                                                     effect1
        track_effect = TrackEffect(effect1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_effect)

        element = self.formatter._saveTrackObject(track_effect)
        self.failUnlessEqual(element.tag, "track-object")
        self.failUnlessEqual(element.attrib["type"],
                qual(track_effect.__class__))
        self.failUnlessEqual(element.attrib["start"], ts(10 * gst.SECOND))
        self.failUnlessEqual(element.attrib["duration"], ts(20 * gst.SECOND))
        self.failUnlessEqual(element.attrib["in_point"], ts(5 * gst.SECOND))
        self.failUnlessEqual(element.attrib["media_duration"],
                ts(15 * gst.SECOND))
        self.failUnlessEqual(element.attrib["priority"], "(int)10")

        effect_element = element.find('effect')
        self.failIfEqual(effect_element, None)
        self.failIfEqual(effect_element.find("factory"), None)
        self.failIfEqual(effect_element.find("gst-element-properties"), None)
开发者ID:dparker18,项目名称:Pitivi,代码行数:35,代码来源:test_etree_formatter.py

示例3: testConnectionAndDisconnection

    def testConnectionAndDisconnection(self):
        timeline = Timeline()
        stream = new_stream()
        factory = new_source_factory()
        track = Track(stream)
        track_object1 = SourceTrackObject(factory, stream)
        track.addTrackObject(track_object1)
        timeline.addTrack(track)
        timeline_object1 = TimelineObject(factory)
        timeline_object1.addTrackObject(track_object1)
        timeline.addTimelineObject(timeline_object1)

        self.observer.startObserving(timeline)
        self.failUnless(timeline.connected)
        self.failUnless(timeline_object1.connected)

        timeline.removeTimelineObject(timeline_object1)
        self.failIf(timeline_object1.connected)

        timeline.addTimelineObject(timeline_object1)
        self.failUnless(timeline_object1)

        self.observer.stopObserving(timeline)
        self.failIf(timeline.connected)
        self.failIf(timeline_object1.connected)
开发者ID:kyotobay,项目名称:pitivi,代码行数:25,代码来源:test_timeline_undo.py

示例4: testSaveTimelineObject

    def testSaveTimelineObject(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = FileSourceFactory("file1.ogg")
        source1.addOutputStream(video_stream)

        # these two calls are needed to populate the context for the -ref
        # elements
        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)
        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        element = self.formatter._saveTimelineObject(timeline_object)
        self.failUnlessEqual(element.tag, "timeline-object")
        self.failIfEqual(element.find("factory-ref"), None)
        track_object_refs = element.find("track-object-refs")
        self.failUnlessEqual(len(track_object_refs), 1)
开发者ID:superdump,项目名称:pitivi,代码行数:28,代码来源:test_etree_formatter.py

示例5: testAudioOnly

    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()
开发者ID:Mathieu69,项目名称:Pitivi_Gargamel,代码行数:46,代码来源:test_timeline_factory.py

示例6: setUp

 def setUp(self):
     self.stream = new_stream()
     self.factory = new_factory()
     self.track1 = Track(self.stream)
     self.track2 = Track(self.stream)
     self.timeline = Timeline()
     self.timeline.addTrack(self.track1)
     self.timeline.addTrack(self.track2)
     self.track_object1 = SourceTrackObject(self.factory, self.stream)
     self.track_object2 = SourceTrackObject(self.factory, self.stream)
     self.track1.addTrackObject(self.track_object1)
     self.track2.addTrackObject(self.track_object2)
     self.timeline_object1 = TimelineObject(self.factory)
     self.timeline_object1.addTrackObject(self.track_object1)
     self.timeline_object1.addTrackObject(self.track_object2)
     self.action_log = UndoableActionLog()
     self.observer = TestTimelineLogObserver(self.action_log)
     self.observer.startObserving(self.timeline)
开发者ID:superdump,项目名称:pitivi,代码行数:18,代码来源:test_timeline_undo.py

示例7: testLoadProject

    def testLoadProject(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        self.formatter._saveTimeline(timeline)

        project = Project()
        project.timeline = timeline
        project.sources.addFactory(source1)

        element = self.formatter._serializeProject(project)

        self.failUnlessEqual(element.tag, "pitivi")
        self.failIfEqual(element.find("factories"), None)
        self.failIfEqual(element.find("timeline"), None)

        indent(element)
        f = file("/tmp/untitled.pptv", "w")
        f.write(tostring(element))
        f.close()
开发者ID:superdump,项目名称:pitivi,代码行数:42,代码来源:test_etree_formatter.py

示例8: testSaveTrack

    def testSaveTrack(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()

        # these two calls are needed to populate the context for the -ref
        # elements
        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        element = self.formatter._saveTrack(track)
        self.failUnlessEqual(element.tag, "track")
        track_objects_element = element.find("track-objects")
        self.failUnlessEqual(len(track_objects_element), 1)
开发者ID:superdump,项目名称:pitivi,代码行数:22,代码来源:test_etree_formatter.py

示例9: testSplitObjectKeyframes

    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,代码行数:37,代码来源:test_track.py

示例10: setUp

    def setUp(self):
        # create a pipeline
        self.pipeline = gst.Pipeline()

        self.track1 = Track(yuv("I420"))
        track_object1 = make_track_object(yuv("I420"))
        track_object2 = make_track_object(yuv("Y42B"))
        track_object3 = make_track_object(yuv("Y444"))
        track_object4 = make_track_object(rgb())
        track_object5 = make_track_object(yuv("AYUV"))

        for i, track_object in enumerate((track_object1, track_object2,
                    track_object3, track_object4, track_object5)):
            self.track1.addTrackObject(track_object)

            # set priorities from 1 to 5
            track_object.priority = i + 1

        # track_object5 falls outside (0s, 15s) so it isn't linked to videomixer
        track_object5.start = 15 * gst.SECOND

        # make a fakesink for the pipeline and connect it as necessary with a callback
        composition = self.track1.composition
        fakesink = gst.element_factory_make('fakesink')

        def bin_pad_added_cb(composition, pad):
            pad.link(fakesink.get_pad('sink'))

        composition.connect("pad-added", bin_pad_added_cb)

        # add the composition and fakesink to the pipeline and set state to paused to preroll
        self.pipeline.add(composition)
        self.pipeline.add(fakesink)
        self.pipeline.set_state(gst.STATE_PAUSED)

        # wait for preroll to complete
        bus = self.pipeline.get_bus()
        msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE,
                gst.MESSAGE_ASYNC_DONE | gst.MESSAGE_ERROR)
        if msg.type == gst.MESSAGE_ERROR:
            gerror, debug = msg.parse_error()
            print "\nError message: %s\nDebug info: %s" % (gerror, debug)
        self.failUnlessEqual(msg.type, gst.MESSAGE_ASYNC_DONE)

        self.svmbin = list(self.track1.mixer.elements())[0]
开发者ID:dparker18,项目名称:Pitivi,代码行数:45,代码来源:test_alpha_passthrough.py

示例11: setUp

    def setUp(self):
        self.mainloop = gobject.MainLoop()

        samples = os.path.join(os.path.dirname(__file__), "samples")
        self.facs = []
        self.facs.append([PictureFileSourceFactory('file://' + os.path.join(samples, "flat_colour1_640x480.png")), VideoStream(gst.Caps("video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"))])
        self.facs.append([PictureFileSourceFactory('file://' + os.path.join(samples, "flat_colour2_640x480.png")), VideoStream(gst.Caps("video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"))])
        self.facs.append([PictureFileSourceFactory('file://' + os.path.join(samples, "flat_colour3_320x180.png")), VideoStream(gst.Caps("video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"))])
        # one video with a different resolution
        self.facs.append([VideoTestSourceFactory(), VideoStream(gst.Caps('video/x-raw-yuv,width=(int)640,height=(int)480,format=(fourcc)I420'))])

        # configure durations and add output streams to factories
        for fac in self.facs:
            factory = fac[0]
            stream = fac[1]
            factory.duration = self.clip_duration
            factory.addOutputStream(stream)
        self.track_objects = []
        self.track = Track(self.facs[0][1])
        self.timeline = Timeline()
        self.timeline.addTrack(self.track)

        vsettings = StreamEncodeSettings(encoder="theoraenc")
        rsettings = RenderSettings(settings=[vsettings],
                                   muxer="oggmux")
        self.fakesink = common.FakeSinkFactory()
        rendersink = RenderSinkFactory(RenderFactory(settings=rsettings),
                                       self.fakesink)
        self.render = RenderAction()
        self.pipeline = Pipeline()
        self.pipeline.connect("eos", self._renderEOSCb)
        self.pipeline.connect("error", self._renderErrorCb)
        self.pipeline.addAction(self.render)
        self.render.addConsumers(rendersink)
        timeline_factory = TimelineSourceFactory(self.timeline)
        self.render.addProducers(timeline_factory)
开发者ID:bemasc,项目名称:pitivi,代码行数:36,代码来源:test_still_image.py

示例12: TestTimelineUndo

class  TestTimelineUndo(TestCase):
    def setUp(self):
        self.stream = new_stream()
        self.factory = new_source_factory()
        self.effect_factory = TestEffectFactory(self.stream)
        self.track1 = Track(self.stream)
        self.track2 = Track(self.stream)
        self.timeline = Timeline()
        self.timeline.addTrack(self.track1)
        self.timeline.addTrack(self.track2)
        self.track_object1 = SourceTrackObject(self.factory, self.stream)
        self.track_object2 = SourceTrackObject(self.factory, self.stream)
        self.track_effect1 = TrackEffect(self.effect_factory, self.stream)
        self.track_effect2 = TrackEffect(self.effect_factory, self.stream)
        self.track1.addTrackObject(self.track_object1)
        self.track2.addTrackObject(self.track_object2)
        self.timeline_object1 = TimelineObject(self.factory)
        self.timeline_object1.addTrackObject(self.track_object1)
        self.timeline_object1.addTrackObject(self.track_object2)
        self.action_log = UndoableActionLog()
        self.observer = TestTimelineLogObserver(self.action_log)
        self.observer.startObserving(self.timeline)

    def testAddTimelineObject(self):
        stacks = []

        def commitCb(action_log, stack, nested):
            stacks.append(stack)
        self.action_log.connect("commit", commitCb)

        self.action_log.begin("add clip")
        self.timeline.addTimelineObject(self.timeline_object1)
        self.action_log.commit()

        self.failUnlessEqual(len(stacks), 1)
        stack = stacks[0]
        self.failUnlessEqual(len(stack.done_actions), 1)
        action = stack.done_actions[0]
        self.failUnless(isinstance(action, TimelineObjectAdded))

        self.failUnless(self.timeline_object1 \
                in self.timeline.timeline_objects)
        self.action_log.undo()
        self.failIf(self.timeline_object1 \
                in self.timeline.timeline_objects)

        self.action_log.redo()
        self.failUnless(self.timeline_object1 \
                in self.timeline.timeline_objects)

    def testRemoveTimelineObject(self):
        stacks = []

        def commitCb(action_log, stack, nested):
            stacks.append(stack)
        self.action_log.connect("commit", commitCb)

        self.timeline.addTimelineObject(self.timeline_object1)
        self.action_log.begin("remove clip")
        self.timeline.removeTimelineObject(self.timeline_object1, deep=True)
        self.action_log.commit()

        self.failUnlessEqual(len(stacks), 1)
        stack = stacks[0]
        self.failUnlessEqual(len(stack.done_actions), 1)
        action = stack.done_actions[0]
        self.failUnless(isinstance(action, TimelineObjectRemoved))

        self.failIf(self.timeline_object1 \
                in self.timeline.timeline_objects)
        self.action_log.undo()
        self.failUnless(self.timeline_object1 \
                in self.timeline.timeline_objects)

        self.action_log.redo()
        self.failIf(self.timeline_object1 \
                in self.timeline.timeline_objects)

    def testAddEffectToTimelineObject(self):
        stacks = []
        pipeline = Pipeline()

        def commitCb(action_log, stack, nested):
            stacks.append(stack)
        self.action_log.connect("commit", commitCb)
        self.observer.pipeline = pipeline

        #FIXME Should I commit it and check there are 2 elements
        #in the stacks
        self.timeline.addTimelineObject(self.timeline_object1)
        self.track1.addTrackObject(self.track_effect1)

        self.action_log.begin("add effect")
        self.timeline_object1.addTrackObject(self.track_effect1)
        self.action_log.commit()

        self.failUnlessEqual(len(stacks), 1)
        stack = stacks[0]
        self.failUnlessEqual(len(stack.done_actions), 1)
        action = stack.done_actions[0]
#.........这里部分代码省略.........
开发者ID:kyotobay,项目名称:pitivi,代码行数:101,代码来源:test_timeline_undo.py

示例13: TestAlpha

class TestAlpha(TestCase):
    def setUp(self):
        # create a pipeline
        self.pipeline = gst.Pipeline()

        self.track1 = Track(yuv("I420"))
        track_object1 = make_track_object(yuv("I420"))
        track_object2 = make_track_object(yuv("Y42B"))
        track_object3 = make_track_object(yuv("Y444"))
        track_object4 = make_track_object(rgb())
        track_object5 = make_track_object(yuv("AYUV"))

        for i, track_object in enumerate((track_object1, track_object2,
                    track_object3, track_object4, track_object5)):
            self.track1.addTrackObject(track_object)

            # set priorities from 1 to 5
            track_object.priority = i + 1

        # track_object5 falls outside (0s, 15s) so it isn't linked to videomixer
        track_object5.start = 15 * gst.SECOND

        # make a fakesink for the pipeline and connect it as necessary with a callback
        composition = self.track1.composition
        fakesink = gst.element_factory_make('fakesink')
        def bin_pad_added_cb(composition, pad):
            pad.link(fakesink.get_pad('sink'))
        composition.connect("pad-added", bin_pad_added_cb)

        # add the composition and fakesink to the pipeline and set state to paused to preroll
        self.pipeline.add(composition)
        self.pipeline.add(fakesink)
        self.pipeline.set_state(gst.STATE_PAUSED)

        # wait for preroll to complete
        bus = self.pipeline.get_bus()
        msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE,
                gst.MESSAGE_ASYNC_DONE | gst.MESSAGE_ERROR)
        if msg.type == gst.MESSAGE_ERROR:
            gerror, debug = msg.parse_error()
            print "\nError message: %s\nDebug info: %s" % (gerror, debug)
        self.failUnlessEqual(msg.type, gst.MESSAGE_ASYNC_DONE)

        self.svmbin = list(self.track1.mixer.elements())[0]

    def tearDown(self):
        self.pipeline.set_state(gst.STATE_NULL)
        TestCase.tearDown(self)

    def failUnlessAlphaIsSet(self):
        # check that each SmartVideomixerBin input has alpha set on its
        # capsfilter
        for input in self.svmbin.inputs.values():
            capsfilter = input[2]
            self.failUnless(capsfilter.props.caps[0].has_key("format"))

    def failUnlessAlphaIsNotSet(self):
        # check that each SmartVideomixerBin input has alpha _not_ set on its
        # capsfilter
        for input in self.svmbin.inputs.values():
            capsfilter = input[2]
            self.failIf(capsfilter.props.caps[0].has_key("format"))

    def testKeyframesOnDifferentObjects(self):
        # no alpha < 1.0 keyframes
        for track_obj in self.track1.track_objects:
            set_all_keyframes(track_obj, 1.0)
        self.failUnlessAlphaIsNotSet()

        track_object1 = self.track1.track_objects[0]
        track_object2 = self.track1.track_objects[1]

        # one alpha < 1.0 keyframe
        set_one_keyframe(track_object1, 0.8)
        self.failUnlessAlphaIsSet()

        # two alpha < 1.0 keyframes
        set_one_keyframe(track_object2, 0.5)
        self.failUnlessAlphaIsSet()

        # one alpha < 1.0 keyframe
        set_one_keyframe(track_object1, 1.0)
        self.failUnlessAlphaIsSet()

        # no alpha < 1.0 keyframes
        set_one_keyframe(track_object2, 1.0)

        self.failUnlessAlphaIsNotSet()

    def testKeyframesOnSameObject(self):
        for track_obj in self.track1.track_objects:
            set_all_keyframes(track_obj, 1.0)
        self.failUnlessAlphaIsNotSet()

        track_object1 = self.track1.track_objects[0]
        interpolator1 = track_object1.getInterpolator("alpha")

        keyframe1 = interpolator1.newKeyframe(1 * gst.SECOND, 0.8)
        self.failUnlessAlphaIsSet()

#.........这里部分代码省略.........
开发者ID:Mathieu69,项目名称:Pitivi_Gargamel,代码行数:101,代码来源:test_alpha_passthrough.py

示例14: testSplitObject

    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,代码行数:71,代码来源:test_track.py

示例15: setUp

 def setUp(self):
     self.factory = StubFactory()
     self.stream = AudioStream(gst.Caps('audio/x-raw-int'))
     self.factory.addOutputStream(self.stream)
     self.track1 = Track(self.stream)
     self.timeline = Timeline()
开发者ID:bemasc,项目名称:pitivi,代码行数:6,代码来源:test_gap.py


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