예제 #1
0
파일: actioner.py 프로젝트: bemasc/pitivi
    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
예제 #2
0
    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
예제 #3
0
    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)
예제 #4
0
    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()
예제 #5
0
    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()
예제 #6
0
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()

        # mix images and videos with the same resolution
        self.configureStreams([0, 1, 3], [0, self.clip_duration, 2 * self.clip_duration])
        self.startRender()
        self.cleanUp()

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

        # mix images and videos with different resolutions by overlapping
        self.configureStreams(range(4), [0, self.clip_duration // 2, self.clip_duration, (3 * self.clip_duration) // 2])
        self.startRender()
        self.cleanUp()
예제 #7
0
    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)
예제 #8
0
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(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 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()

        # mix images and videos with the same resolution
        self.configureStreams([0, 1, 3],
                              [0, self.clip_duration, 2 * self.clip_duration])
        self.startRender()
        self.cleanUp()

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

        # mix images and videos with different resolutions by overlapping
        self.configureStreams(range(4), [
            0, self.clip_duration // 2, self.clip_duration,
            (3 * self.clip_duration) // 2
        ])
        self.startRender()
        self.cleanUp()
예제 #9
0
파일: test_action.py 프로젝트: qlf/Pitivi
    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()
예제 #10
0
파일: test_action.py 프로젝트: qlf/Pitivi
    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()