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