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


Python Pipeline.play方法代码示例

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


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

示例1: testMultiple

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import play [as 别名]
    def testMultiple(self):
        """Test a dual stream encoding with separates sources"""
        settings = RenderSettings(settings=[self.asettings, self.vsettings],
                                  muxer="oggmux")
        sf = RenderSinkFactory(RenderFactory(settings=settings),
                               common.FakeSinkFactory())
        a = RenderAction()
        a.addConsumers(sf)
        a.addProducers(self.vsrc, self.asrc)

        p = Pipeline()
        a.setPipeline(p)

        a.activate()
        self.assertEquals(len(a._links), 2)

        p.play()
        time.sleep(3)
        p.getState()
        p.stop()
        a.deactivate()

        a.unsetPipeline()

        p.release()
开发者ID:bemasc,项目名称:pitivi,代码行数:27,代码来源:test_action.py

示例2: testSimpleStreams

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import play [as 别名]
    def testSimpleStreams(self):
        """Test a RenderSettings with exact stream settings"""
        # let's force the video to some unusual size
        outs = VideoStream(gst.Caps("video/x-raw-yuv,width=624,height=230,framerate=10/1"))
        fset = StreamEncodeSettings(encoder="theoraenc", input_stream=outs)
        settings = RenderSettings(settings=[fset], muxer="oggmux")
        sf = RenderSinkFactory(RenderFactory(settings=settings),
                               common.FakeSinkFactory())

        a = RenderAction()
        a.addConsumers(sf)
        a.addProducers(self.vsrc)

        p = Pipeline()
        a.setPipeline(p)

        a.activate()
        self.assertEquals(len(a._links), 1)

        p.play()
        time.sleep(3)
        p.getState()
        p.stop()
        a.deactivate()

        p.release()
开发者ID:bemasc,项目名称:pitivi,代码行数:28,代码来源:test_action.py

示例3: TestStillImage

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import play [as 别名]
class TestStillImage(TestCase):
    clip_duration = 3 * Gst.SECOND

    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(renderer="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)

    def tearDown(self):
        self.mainloop.quit()

    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

    def startRender(self):
        self.render.activate()
        self.data_written = 0
        self.fakesink.bins[0].props.signal_handoffs = True
        self.fakesink.bins[0].connect("handoff", self._fakesinkHandoffCb)
        self.pipeline.play()
        self.mainloop.run()

    def _fakesinkHandoffCb(self, fakesink, buf, pad):
        self.data_written += buf.size

    def _renderEOSCb(self, obj):
        self.mainloop.quit()
        # check the render was successful
        self.assertTrue(self.data_written > 0)

    def _renderErrorCb(self, obj, error, details):
        print "Error: %s\nDetails: %s" % (str(error), str(details))
        self.fail("Pipeline rendering error")

    def cleanUp(self):
        self.render.deactivate()
        self.track.removeAllTrackObjects()
        self.track_objects = []

    def testRendering(self):
        # use one of the still image streams
        self.configureStreams(range(1), [0])
        self.startRender()
        self.cleanUp()

        # use two images with the same resolution and concatenate them
        self.configureStreams(range(2), [0, self.clip_duration])
        self.startRender()
        self.cleanUp()

        # concatenate images with different resolutions
        self.configureStreams(range(3), [0, self.clip_duration, 2 * self.clip_duration])
        self.startRender()
        self.cleanUp()

        # mix images with different resolutions by overlapping
        self.configureStreams(range(3), [0, self.clip_duration // 2, self.clip_duration])
        self.startRender()
        self.cleanUp()

#.........这里部分代码省略.........
开发者ID:palango,项目名称:pitivi,代码行数:103,代码来源:test_still_image.py

示例4: TestPipeline

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import play [as 别名]

#.........这里部分代码省略.........

        self.pipeline.removeAction(ac2)
        p2.release()

    def testStateChange(self):
        loop = gobject.MainLoop()

        bag = {"last_state": None}
        def state_changed_cb(pipeline, state, bag, loop):
            bag["last_state"] = state
            loop.quit()

        self.pipeline.connect('state-changed', state_changed_cb, bag, loop)

        # playing
        self.pipeline.setState(STATE_PLAYING)
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_PLAYING)
        self.failUnlessEqual(self.pipeline.getState(), STATE_PLAYING)
        self.assertEquals(self.monitor.state_changed_count, 1)

        # playing again
        self.pipeline.setState(STATE_PLAYING)
        self.assertEquals(self.monitor.state_changed_count, 1)

        # ready
        self.pipeline.setState(STATE_READY)
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_READY)
        self.failUnlessEqual(self.pipeline.getState(), STATE_READY)
        self.assertEquals(self.monitor.state_changed_count, 2)

        # PLAYING
        self.pipeline.play()
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_PLAYING)
        self.failUnlessEqual(self.pipeline.getState(), STATE_PLAYING)
        self.assertEquals(self.monitor.state_changed_count, 3)

        # PAUSE
        self.pipeline.pause()
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_PAUSED)
        self.failUnlessEqual(self.pipeline.getState(), STATE_PAUSED)
        self.assertEquals(self.monitor.state_changed_count, 4)

        self.pipeline.stop()
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_READY)
        self.failUnlessEqual(self.pipeline.getState(), STATE_READY)
        self.assertEquals(self.monitor.state_changed_count, 5)

    def testGetReleaseBinForFactoryStream(self):
        factory = VideoTestSourceFactory()
        stream = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                'src0')
        factory.addOutputStream(stream)

        # try to get a cached instance
        self.failUnlessRaises(PipelineError,
                self.pipeline.getBinForFactoryStream, factory, stream, False)

        # create a bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(bin1, gst.Element))
        # return the cached instance
开发者ID:bemasc,项目名称:pitivi,代码行数:70,代码来源:test_pipeline.py


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