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()
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()
def _createAction(self, sources): """Creates a L{RenderAction}.""" settings = export_settings_to_render_settings(self.settings, self.have_video, self.have_audio) sf = RenderSinkFactory(RenderFactory(settings=settings), URISinkFactory(uri=self.outfile)) a = RenderAction() a.addProducers(*sources) a.addConsumers(sf) return a
def testMakeBin(self): rset = RenderSettings( settings=[self.audiosettings, self.videosettings], muxer="oggmux") f = RenderFactory(settings=rset) bin = f.makeBin() self.assertEquals(bin.factory, f) # it should be a bin... self.assertEquals(type(bin), gst.Bin) # containing 2 bins (encoders) and the muxer elements = list(bin.elements()) self.assertEquals(len(elements), 3) for elt in elements: if type(elt) == gst.Bin: # it's one of our encoders self.assertEquals(len(list(elt.elements())), 1) else: # it's our muxer ! self.assertEquals(elt.get_factory().get_name(), "oggmux")
def testMakeBin(self): rset = RenderSettings(settings=[self.audiosettings, self.videosettings], muxer="oggmux") f = RenderFactory(settings=rset) bin = f.makeBin() self.assertEquals(bin.factory, f) # it should be a bin... self.assertEquals(type(bin), gst.Bin) # containing 2 bins (encoders) and the muxer elements = list(bin.elements()) self.assertEquals(len(elements), 3) for elt in elements: if type(elt) == gst.Bin: # it's one of our encoders self.assertEquals(len(list(elt.elements())), 1) else: # it's our muxer ! self.assertEquals(elt.get_factory().get_name(), "oggmux")
def render_action_for_uri(uri, settings, *factories): """Creates a L{RenderAction}. @param uri: The destination uri @type uri: C{URI} @param settings: The settings @type settings: L{RenderSettings} @param factories: The source factories @type factories: L{SourceFactory} @returns: The action @rtype: L{RenderAction} """ from pitivi.factories.file import URISinkFactory sf = RenderSinkFactory(RenderFactory(settings=settings), URISinkFactory(uri=uri)) a = RenderAction() a.addProducers(*factories) a.addConsumers(sf) return a
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)
def testSimple(self): rset = RenderSettings(settings=[self.audiosettings, self.videosettings], muxer="oggmux") f = RenderFactory(settings=rset) self.assertEquals(f.settings, rset)