예제 #1
0
    def _add_video_effects(self):
        # Add the effects to the component but don't plug them until we have a
        # valid video pad
        props = self.config['properties']
        is_square = props.get('is-square', False)
        add_borders = props.get('add-borders', False)
        width = props.get('width', None)
        height = props.get('height', None)
        # Expressed in ms
        interval = props.get('keyunits-interval', 10000) * gst.MSECOND
        fr = props.get('framerate', (25, 2))
        framerate = gst.Fraction(fr[0], fr[1])

        self.vr = videorate.Videorate('videorate', None, self.pipeline,
                                      framerate)
        self.addEffect(self.vr)
        #self.vr.effectBin.set_state(gst.STATE_PLAYING)
        self.debug("Videorate added")

        self.videoscaler = videoscale.Videoscale('videoscale', self, None,
                                                 self.pipeline, width, height,
                                                 is_square, add_borders)
        self.addEffect(self.videoscaler)
        #self.videoscaler.effectBin.set_state(gst.STATE_PLAYING)
        self.debug("Videoscaler  added")

        self.vkuscheduler = kuscheduler.KeyUnitsScheduler(
            'keyunits-scheduler', None, self.pipeline, interval)
        self.addEffect(self.vkuscheduler)
        self.debug("KeyUnitsScheduler added")
예제 #2
0
    def configure_pipeline(self, pipeline, properties):
        self.volume = pipeline.get_by_name("setvolume")
        from flumotion.component.effects.volume import volume
        comp_level = pipeline.get_by_name('volumelevel')
        vol = volume.Volume('inputVolume', comp_level, pipeline)
        self.addEffect(vol)

        deinterlacer = deinterlace.Deinterlace(
            'deinterlace',
            pipeline.get_by_name("src").get_pad("src_video"), pipeline,
            self.deintMode, self.deintMethod)
        self.addEffect(deinterlacer)
        deinterlacer.plug()

        videoscaler = videoscale.Videoscale(
            'videoscale', self, deinterlacer.effectBin.get_pad("src"),
            pipeline, self.width, self.height, True, False)
        self.addEffect(videoscaler)
        videoscaler.plug()

        # Setting a tolerance of 20ms should be enough (1/2 frame), but
        # we set it to 40ms to be more conservatives
        ar = audiorate.Audiorate('audiorate',
                                 comp_level.get_pad("src"),
                                 pipeline,
                                 tolerance=40 * gst.MSECOND)
        self.addEffect(ar)
        ar.plug()
예제 #3
0
    def _add_video_effects(self, pipeline):
        # Add deinterlacer
        deinterlacer = deinterlace.Deinterlace(
            'deinterlace',
            self.get_raw_video_element().get_pad("src"), pipeline,
            self.deintMode, self.deintMethod)
        self.addEffect(deinterlacer)
        deinterlacer.plug()

        # Add video rate converter
        rateconverter = videorate.Videorate(
            'videorate', deinterlacer.effectBin.get_pad("src"), pipeline,
            self.framerate)
        self.addEffect(rateconverter)
        rateconverter.plug()

        # Add video scaler
        videoscaler = videoscale.Videoscale(
            'videoscale', self, rateconverter.effectBin.get_pad("src"),
            pipeline, self.width, self.height, self.is_square,
            self.add_borders)
        self.addEffect(videoscaler)
        videoscaler.plug()

        # Add key units scheduler
        scheduler = kuscheduler.KeyUnitsScheduler(
            'video-kuscheduler', videoscaler.effectBin.get_pad("src"),
            pipeline, self.kuinterval)
        self.addEffect(scheduler)
        scheduler.plug()
예제 #4
0
    def configure_pipeline(self, pipeline, properties):
        self.deintMode = properties.get('deinterlace-mode', "auto")
        self.deintMethod = properties.get('deinterlace-method', "ffmpeg")
        self.width = properties.get('width', None)
        self.height = properties.get('height', None)
        self.is_square = properties.get('is-square', False)
        fr = properties.get('framerate', None)
        self.framerate = None
        if fr is not None:
            self.framerate = gst.Fraction(fr[0], fr[1])

        identity = pipeline.get_by_name("identity")
        # Add videorate effect. The videorate is usually decreased, so it's
        # usefull to have this effect always first, because it reduces the
        # number of frames to process.
        vr = videorate.Videorate('videorate', identity.get_pad("src"),
                                 pipeline, self.framerate)
        self.addEffect(vr)
        vr.plug()
        # Add deinterlace effect. Deinterlacing must always be done
        # before scaling.
        deinterlacer = deinterlace.Deinterlace('deinterlace',
                                               vr.effectBin.get_pad("src"),
                                               pipeline, self.deintMode,
                                               self.deintMethod)
        self.addEffect(deinterlacer)
        deinterlacer.plug()
        # Add videoscale effect
        videoscaler = videoscale.Videoscale(
            'videoscale', self, deinterlacer.effectBin.get_pad("src"),
            pipeline, self.width, self.height, self.is_square)
        self.addEffect(videoscaler)
        videoscaler.plug()
예제 #5
0
파일: video.py 프로젝트: sharky93/flumotion
    def configure_pipeline(self, pipeline, properties):
        self.deintMode = properties.get('deinterlace-mode', "auto")
        self.deintMethod = properties.get('deinterlace-method', "ffmpeg")
        self.width = properties.get('width', None)
        self.height = properties.get('height', None)
        self.widthCorrection = properties.get('width-correction', 8)
        self.heightCorrection = properties.get('height-correction', 0)
        self.is_square = properties.get('is-square', False)

        identity = pipeline.get_by_name("identity")
        # FIXME: The deinterlace effect uses a videorate which we don't want in
        # the middle of a flow.
        # Add deinterlace effect. Deinterlacing must always be done
        # before scaling.
        #deinterlacer = deinterlace.Deinterlace('deinterlace',
        #    identity.get_pad("src"),
        #    pipeline, self.deintMode, self.deintMethod)
        #self.addEffect(deinterlacer)
        #deinterlacer.plug()
        # Add videoscale effect
        videoscaler = videoscale.Videoscale('videoscale', self,
                                            identity.get_pad("src"), pipeline,
                                            self.width, self.height,
                                            self.is_square, False,
                                            self.widthCorrection,
                                            self.heightCorrection)
        self.addEffect(videoscaler)
        videoscaler.plug()
예제 #6
0
    def configure_pipeline(self, pipeline, properties):
        self.volume = pipeline.get_by_name("setvolume")
        from flumotion.component.effects.volume import volume
        comp_level = pipeline.get_by_name('volumelevel')
        vol = volume.Volume('inputVolume', comp_level, pipeline)
        # catch bus message for when camera disappears
        bus = pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect('message::element', self._bus_message_received_cb)
        self.addEffect(vol)

        decoder = pipeline.get_by_name("decoder")
        if gstreamer.element_has_property(decoder, 'drop-factor'):
            if self.framerate:
                framerate = float(self.framerate.num / self.framerate.denom)
                if 12.5 < framerate:
                    drop_factor = 1
                elif 6.3 < framerate <= 12.5:
                    drop_factor = 2
                elif 3.2 < framerate <= 6.3:
                    drop_factor = 4
                elif framerate <= 3.2:
                    drop_factor = 8
            else:
                drop_factor = 1
            decoder.set_property('drop-factor', drop_factor)

        vr = videorate.Videorate('videorate',
            decoder.get_pad("src"), pipeline, self.framerate)
        self.addEffect(vr)
        vr.plug()

        deinterlacer = deinterlace.Deinterlace('deinterlace',
            vr.effectBin.get_pad("src"), pipeline,
            self.deintMode, self.deintMethod)
        self.addEffect(deinterlacer)
        deinterlacer.plug()

        videoscaler = videoscale.Videoscale('videoscale', self,
            deinterlacer.effectBin.get_pad("src"), pipeline,
            self.width, self.height, self.is_square, self.add_borders)
        self.addEffect(videoscaler)
        videoscaler.plug()

        # Setting a tolerance of 20ms should be enough (1/2 frame), but
        # we set it to 40ms to be more conservatives
        ar = audioconvert.Audioconvert('audioconvert',
                                       comp_level.get_pad("src"),
                                       pipeline, tolerance=40 * gst.MSECOND)
        self.addEffect(ar)
        ar.plug()
예제 #7
0
    def configure_pipeline(self, pipeline, properties):
        video = pipeline.get_by_name('video')
        vr = videorate.Videorate('videorate', video.get_pad("src"), pipeline,
                                 self.framerate)
        self.addEffect(vr)
        vr.plug()

        deinterlacer = deinterlace.Deinterlace('deinterlace',
                                               vr.effectBin.get_pad("src"),
                                               pipeline, self.deintMode,
                                               self.deintMethod)
        self.addEffect(deinterlacer)
        deinterlacer.plug()

        videoscaler = videoscale.Videoscale(
            'videoscale', self, deinterlacer.effectBin.get_pad("src"),
            pipeline, self.width, self.height, self.is_square,
            self.add_borders)
        self.addEffect(videoscaler)
        videoscaler.plug()