Exemplo n.º 1
0
    def check_gst_elements_available (self):
        message = ""

        # gst-plugins-bad
        if (gst.element_factory_find ("vp8enc") == None):
            message += _("Element vp8enc missing: this is normally found in package gstreamer-plugins-bad\n")
        # gst-plugins-good
        if (gst.element_factory_find ("videomixer") == None):
            message += _("Element videomixer missing: this is normally found in package gstreamer-plugins-good\n")

        # gst-plugins-base
        if (gst.element_factory_find ("videoscale") == None):
            message += _("Element videoscale missing: this is normally found in package gstreamer-plugins-base\n")

        # gst-alsa
        if (gst.element_factory_find ("alsasrc") == None):
            message += _("Element alsasrc missing: this is normally found in gstreamer-alsa\n")

        if (message == ""):
            return

        dialog = Gtk.MessageDialog (self.mainWindow, 0, Gtk.MessageType.ERROR,
                                   Gtk.ButtonsType.CANCEL,
                                    _("Required gstreamer element missing"))
        dialog.format_secondary_text (message)

        dialog.run ()

        dialog.destroy ()
Exemplo n.º 2
0
def register(controller=None):
    if (gst.element_factory_find('vader')
         and gst.element_factory_find('pocketsphinx')):
        controller.register_importer(PocketSphinxImporter)
    else:
        controller.log(_("Cannot register speech recognition: Pocketsphinx plugins not found. See http://cmusphinx.sourceforge.net/wiki/gstreamer for details."))
    return True
Exemplo n.º 3
0
def register(controller=None):
    if (gst.element_factory_find('vader')
            and gst.element_factory_find('pocketsphinx')):
        controller.register_importer(PocketSphinxImporter)
    else:
        controller.log(
            _("Cannot register speech recognition: Pocketsphinx plugins not found. See http://cmusphinx.sourceforge.net/wiki/gstreamer for details."
              ))
    return True
Exemplo n.º 4
0
def register(controller):
    if ( gst is not None
         and gst.element_factory_find('gnlcomposition')
         and gst.element_factory_find('gnlfilesource')
         and gst.element_factory_find('theoraenc')
         and gst.element_factory_find('vorbisenc')
         and gst.element_factory_find('oggmux') ):
        controller.register_generic_feature(name, MontageRenderer)
    else:
        controller.log(_("Cannot register montage renderer: Gnonlin plugins are not present."))
Exemplo n.º 5
0
def register(controller):
    if (gst is not None and gst.element_factory_find('gnlcomposition')
            and gst.element_factory_find('gnlfilesource')
            and gst.element_factory_find('theoraenc')
            and gst.element_factory_find('vorbisenc')
            and gst.element_factory_find('oggmux')):
        controller.register_generic_feature(name, MontageRenderer)
    else:
        controller.log(
            _("Cannot register montage renderer: Gnonlin plugins are not present."
              ))
Exemplo n.º 6
0
	def __init__(self, shell):
		# make sure the replaygain elements are available
		missing = []
		required = ("rgvolume", "rglimiter")
		for e in required:
			if gst.element_factory_find(e) is None:
				missing.append(e)

		if len(missing) > 0:
			msg = _("The GStreamer elements required for ReplayGain processing are not available. The missing elements are: %s") % ", ".join(missing)
			rb.error_dialog(shell.props.window, _("ReplayGain GStreamer plugins not available"), msg)
			raise Exception(msg)

		self.shell_player = shell.props.shell_player
		self.player = self.shell_player.props.player
		self.gconf = gconf.client_get_default()

		self.gconf.add_dir(config.GCONF_DIR, preload=False)
		self.gconf.notify_add(config.GCONF_KEYS['limiter'], self.limiter_changed_cb)

		self.previous_gain = []
		self.fallback_gain = 0.0
		self.resetting_rgvolume = False

		# we use different means to hook into the playback pipeline depending on
		# the playback backend in use
		if gobject.signal_lookup("get-stream-filters", self.player):
			self.setup_xfade_mode()
			self.deactivate_backend = self.deactivate_xfade_mode
		else:
			self.setup_playbin2_mode()
			self.deactivate_backend = self.deactivate_playbin2_mode
Exemplo n.º 7
0
 def detect_element(self, name, text, pipe='%s'):
     try:
         if gst.element_factory_find(name):
             element = gst.element_factory_make(name,
                 '%spresencetest' % name)
             if isinstance(element, gst.interfaces.PropertyProbe):
                 element.set_state(gst.STATE_READY)
                 element.probe_property_name('device')
                 devices = element.probe_get_values_name('device')
                 if devices:
                     self.devices[text % _(' Default device')] = pipe % name
                     for device in devices:
                         element.set_state(gst.STATE_NULL)
                         element.set_property('device', device)
                         element.set_state(gst.STATE_READY)
                         device_name = element.get_property('device-name')
                         self.devices[text % device_name] = pipe % \
                             '%s device=%s' % (name, device)
                 element.set_state(gst.STATE_NULL)
             else:
                 self.devices[text] = pipe % name
     except ImportError:
         pass
     except gst.ElementNotFoundError:
         print 'element \'%s\' not found' % name
Exemplo n.º 8
0
    def _displaySettings(self):
        self.width = self.settings.videowidth
        self.height = self.settings.videoheight

        # Video settings
        self.frame_rate_combo.set_model(frame_rates)
        set_combo_value(self.frame_rate_combo, self.settings.videorate)
        self.scale_spinbutton.set_value(100)
        self.updateResolution()

        # Audio settings
        self.channels_combo.set_model(audio_channels)
        set_combo_value(self.channels_combo, self.settings.audiochannels)

        self.sample_rate_combo.set_model(audio_rates)
        set_combo_value(self.sample_rate_combo, self.settings.audiorate)

        self.sample_depth_combo.set_model(audio_depths)
        set_combo_value(self.sample_depth_combo, self.settings.audiodepth)

        # Muxer
        self.muxercombobox.set_model(factorylist(
            self.settings.muxers))
        # note: this will trigger an update of the codec comboboxes
        set_combo_value(self.muxercombobox, 
            gst.element_factory_find(self.settings.muxer))

        # Encoder/Muxer settings

        # File
        self.filebutton.set_current_folder(self.app.settings.lastExportFolder)
        self.updateFilename(self.project.name)

        # Summary
        self._updateSummary()
Exemplo n.º 9
0
    def __init__(self, shell):
        # make sure the replaygain elements are available
        missing = []
        required = ("rgvolume", "rglimiter")
        for e in required:
            if gst.element_factory_find(e) is None:
                missing.append(e)

        if len(missing) > 0:
            msg = _(
                "The GStreamer elements required for ReplayGain processing are not available. The missing elements are: %s"
            ) % ", ".join(missing)
            RB.error_dialog(shell.props.window,
                            _("ReplayGain GStreamer plugins not available"),
                            msg)
            raise Exception(msg)

        self.shell_player = shell.props.shell_player
        self.player = self.shell_player.props.player
        self.settings = Gio.Settings("org.gnome.rhythmbox.plugins.replaygain")

        self.settings.connect("changed::limiter", self.limiter_changed_cb)

        self.previous_gain = []
        self.fallback_gain = 0.0
        self.resetting_rgvolume = False

        # we use different means to hook into the playback pipeline depending on
        # the playback backend in use
        if gobject.signal_lookup("get-stream-filters", self.player):
            self.setup_xfade_mode()
            self.deactivate_backend = self.deactivate_xfade_mode
        else:
            self.setup_playbin2_mode()
            self.deactivate_backend = self.deactivate_playbin2_mode
Exemplo n.º 10
0
	def __init__(self, shell):
		# make sure the replaygain elements are available
		missing = []
		required = ("rgvolume", "rglimiter")
		for e in required:
			if gst.element_factory_find(e) is None:
				missing.append(e)

		if len(missing) > 0:
			msg = _("The GStreamer elements required for ReplayGain processing are not available. The missing elements are: %s") % ", ".join(missing)
			RB.error_dialog(shell.props.window, _("ReplayGain GStreamer plugins not available"), msg)
			raise Exception(msg)

		self.shell_player = shell.props.shell_player
		self.player = self.shell_player.props.player
		self.settings = Gio.Settings("org.gnome.rhythmbox.plugins.replaygain")

		self.settings.connect("changed::limiter", self.limiter_changed_cb)

		self.previous_gain = []
		self.fallback_gain = 0.0
		self.resetting_rgvolume = False

		# we use different means to hook into the playback pipeline depending on
		# the playback backend in use
		if gobject.signal_lookup("get-stream-filters", self.player):
			self.setup_xfade_mode()
			self.deactivate_backend = self.deactivate_xfade_mode
		else:
			self.setup_playbin2_mode()
			self.deactivate_backend = self.deactivate_playbin2_mode
Exemplo n.º 11
0
def vsinkDef():
    """
    The method returns the first videosink that is available on the system.
    """
    for x in globals.vsinkTypes:
        if gst.element_factory_find(x):
            return x

    return None    
Exemplo n.º 12
0
def vsinkDef():
    """
    The method returns the first videosink that is available on the system.
    """
    for x in globals.vsinkTypes:
        if gst.element_factory_find(x):
            return x

    return None
Exemplo n.º 13
0
def is_gstreamer_element_found(name):
    """
    Checks if a given Gstreamer element is installed.
    @rettype: bool
    """
    ok = gst.element_factory_find(name) is not None
    if not ok:
        log.info("Could not find Gstreamer element %s." % (name))
    return ok
Exemplo n.º 14
0
def is_gstreamer_element_found(name):
    """
    Checks if a given Gstreamer element is installed.
    @rettype: bool
    """
    ok = gst.element_factory_find(name) is not None
    if not ok:
        log.info("Could not find Gstreamer element %s." % (name))
    return ok
Exemplo n.º 15
0
 def _displayRenderSettings(self):
     """Display the settings which can be changed only in the RenderDialog.
     """
     # Video settings
     # note: this will trigger an update of the video resolution label
     self.scale_spinbutton.set_value(self.settings.render_scale)
     # Muxer settings
     # note: this will trigger an update of the codec comboboxes
     set_combo_value(self.muxercombobox,
         gst.element_factory_find(self.settings.muxer))
Exemplo n.º 16
0
def check_system():
    for element in [ "gnlcomposition", "kenburns", "videomixer", "textoverlay", "imagefreeze", "alpha", ]:
        if gst.element_factory_find(element) is None:
            raise Exception("Gstreamer element '%s' is not installed. Please install the appropriate gstreamer plugin and try again." % (element,))

        try:
            x = gst.element_factory_make("videotestsrc")
            x.props.foreground_color
        except AttributeError:
            raise Exception("Your gstreamer version is too old. Install version 0.10.31 or newer.")
Exemplo n.º 17
0
 def _updateEncoderCombo(self, encoder_combo, preferred_encoder):
     """Select the specified encoder for the specified encoder combo."""
     if preferred_encoder:
         # A preferrence exists, pick it if it can be found in
         # the current model of the combobox.
         vencoder = gst.element_factory_find(preferred_encoder)
         set_combo_value(encoder_combo, vencoder, default_index=0)
     else:
         # No preferrence exists, pick the first encoder from
         # the current model of the combobox.
         encoder_combo.set_active(0)
 def __new__(klass, sink_name, test_results):
     sink = gst.element_factory_find(sink_name)
     if not sink:
         raise Exception("Sink %s not found" % sink_name)
     if sink.get_klass() == 'Sink/Video':
         klass = VideoSinkTest
     elif sink.get_klass() == 'Sink/Audio':
         klass = AudioSinkTest
     else:
         raise Exception("Sink %s is not and audio or video sink" % sink_name)
     return klass(sink_name, test_results)
Exemplo n.º 19
0
def get_formats():
    ret = {}
    for name, value in FORMATS.iteritems():
        try:
            for plug in value["plugins"]:
                x = gst.element_factory_find(plug)
                if not x:
                    raise
            ret[name] = value
        except:    
            pass
    return ret    
Exemplo n.º 20
0
def get_formats():
    ret = {}
    for name, val in FORMATS.iteritems():
        try:
            for plug in val['plugins']:
                x = gst.element_factory_find(plug)
                if not x:
                    raise
            ret[name] = val
        except:
            pass
    return ret
Exemplo n.º 21
0
def get_formats():
    ret = {}
    for name, value in FORMATS.iteritems():
        try:
            for plug in value["plugins"]:
                x = gst.element_factory_find(plug)
                if not x:
                    raise TranscodeError("don't support this format")
            ret[name] = value
        except:    
            pass
    return ret    
Exemplo n.º 22
0
def get_formats():
    ret = {}
    for name, value in FORMATS.iteritems():
        try:
            for plug in value["plugins"]:
                x = gst.element_factory_find(plug)
                if not x:
                    raise TranscodeError("don't support this format")
            ret[name] = value
        except:
            pass
    return ret
Exemplo n.º 23
0
    def _displayRenderSettings(self):
        """Display the settings which can be changed only in the EncodingDialog.
        """
        # Video settings
        # note: this will trigger an update of the video resolution label
        self.scale_spinbutton.set_value(self.settings.render_scale)
        # Muxer settings
        # note: this will trigger an update of the codec comboboxes
        set_combo_value(self.muxercombobox,
            gst.element_factory_find(self.settings.muxer))

        # File
        self.filebutton.set_current_folder(self.app.settings.lastExportFolder)
        self.updateFilename(self.project.name)
Exemplo n.º 24
0
    def muxer_setter(self, widget, value):
        set_combo_value(widget, gst.element_factory_find(value))
        self.settings.setEncoders(muxer=value)

        # Update the extension of the filename.
        basename = os.path.splitext(self.fileentry.get_text())[0]
        self.updateFilename(basename)

        # Update muxer-dependent widgets.
        self.muxer_combo_changing = True
        try:
            self.updateAvailableEncoders()
        finally:
            self.muxer_combo_changing = False
Exemplo n.º 25
0
class H264DecWrapper(DecoderWrapper):
    """ Wrapper for ffdec_h264 Element """

    __gstdetails__ = (
        "ffdec_h264wrapper plugin",
        "Codec/Decoder/Video",
        "Wrapper for ffdec_h264, that deletes all timestamps except for keyframes",
        "Jan Schole <*****@*****.**>")

    # The decoder to wrap:
    __decoder_factory__ = gst.element_factory_find('ffdec_h264')

    # Copy the pad-templates from the decoder:
    __gsttemplates__ = tuple([templ.get() for templ in __decoder_factory__.get_static_pad_templates()])

    def __init__(self, *args, **kwargs):
        DecoderWrapper.__init__(self, *args, **kwargs)
Exemplo n.º 26
0
def check_system():
    for element in [
            "gnlcomposition",
            "kenburns",
            "videomixer",
            "textoverlay",
            "imagefreeze",
            "alpha",
    ]:
        if gst.element_factory_find(element) is None:
            raise Exception(
                "Gstreamer element '%s' is not installed. Please install the appropriate gstreamer plugin and try again."
                % (element, ))

        try:
            x = gst.element_factory_make("videotestsrc")
            x.props.foreground_color
        except AttributeError:
            raise Exception(
                "Your gstreamer version is too old. Install version 0.10.31 or newer."
            )
Exemplo n.º 27
0
def checkElement(element):
    """
    takes an element description (including properties in a gst-launch style
    and checks whether the element exists
    (and whether the properties are could be set in theory)
    """
    elements=element.split()
    name=elements[0]
    try:
        factory=gst.element_factory_find(name)
        if factory is None:
            return False

        e=factory.create()
        for propstring in elements[1:]:
            prop=propstring.split('=')[0]
            x=e.get_property(prop)
        del e
        del factory
    except:
        return False
    return True
Exemplo n.º 28
0
def GStreamerSink(pipeline):
    """Try to create a GStreamer pipeline:
    * Try making the pipeline (defaulting to gconfaudiosink or
      autoaudiosink on Windows).
    * If it fails, fall back to autoaudiosink.
    * If that fails, return None

    Returns the pipeline's description and a list of disconnected elements."""

    if not pipeline and not gst.element_factory_find('gconfaudiosink'):
        pipeline = "autoaudiosink"
    elif not pipeline or pipeline == "gconf":
        pipeline = "gconfaudiosink profile=music"

    try: pipe = [gst.parse_launch(element) for element in pipeline.split('!')]
    except gobject.GError:
        print_w(_("Invalid GStreamer output pipeline, trying default."))
        try: pipe = [gst.parse_launch("autoaudiosink")]
        except gobject.GError: pipe = None
        else: pipeline = "autoaudiosink"

    if pipe:
        # In case the last element is linkable with a fakesink
        # it is not an audiosink, so we append the default pipeline
        fake = gst.element_factory_make('fakesink')
        try:
            gst.element_link_many(pipe[-1], fake)
        except gst.LinkError: pass
        else:
            gst.element_unlink_many(pipe[-1], fake)
            default, default_text = GStreamerSink("")
            if default:
                return pipe + default, pipeline + " ! "  + default_text
    else:
        print_w(_("Could not create default GStreamer pipeline."))

    return pipe, pipeline
Exemplo n.º 29
0
    def __init__(self, shell):
        # make sure the replaygain elements are available
        missing = []
        required = ("rgvolume", "rglimiter")
        for e in required:
            if gst.element_factory_find(e) is None:
                missing.append(e)

        if len(missing) > 0:
            msg = _(
                "The GStreamer elements required for ReplayGain processing are not available. The missing elements are: %s"
            ) % ", ".join(missing)
            rb.error_dialog(shell.props.window,
                            _("ReplayGain GStreamer plugins not available"),
                            msg)
            raise Exception(msg)

        self.shell_player = shell.props.shell_player
        self.player = self.shell_player.props.player
        self.gconf = gconf.client_get_default()

        self.gconf.add_dir(config.GCONF_DIR, preload=False)
        self.gconf.notify_add(config.GCONF_KEYS['limiter'],
                              self.limiter_changed_cb)

        self.previous_gain = []
        self.fallback_gain = 0.0
        self.resetting_rgvolume = False

        # we use different means to hook into the playback pipeline depending on
        # the playback backend in use
        if gobject.signal_lookup("get-stream-filters", self.player):
            self.setup_xfade_mode()
            self.deactivate_backend = self.deactivate_xfade_mode
        else:
            self.setup_playbin2_mode()
            self.deactivate_backend = self.deactivate_playbin2_mode
Exemplo n.º 30
0
 def vcodec_setter(self, widget, value):
     set_combo_value(widget, gst.element_factory_find(value))
     self.settings.setEncoders(vencoder=value)
     if not self.muxer_combo_changing:
         # The user directly changed the video encoder combo.
         self.preferred_vencoder = value
Exemplo n.º 31
0
        pipeline = _GCONF.get_string(_GCONF_PROFILE_PATH + name + "/pipeline")
        # check profile validity
        if not extension or not pipeline:
            continue
        if not description:
            description = extension
        if description in audio_profiles_dict:
            continue
        # store
        profile = description, extension, pipeline
        audio_profiles_list.append(profile)
        audio_profiles_dict[description] = profile

required_elements = ("decodebin", "fakesink", "audioconvert", "typefind", "audiorate")
for element in required_elements:
    if not gst.element_factory_find(element):
        print "required gstreamer element '%s' not found." % element
        sys.exit(1)

if gst.element_factory_find("giosrc"):
    gstreamer_source = "giosrc"
    gstreamer_sink = "giosink"
    encode_filename = vfs_encode_filename
    use_gnomevfs = True
    print "  using gio"
elif gst.element_factory_find("gnomevfssrc"):
    gstreamer_source = "gnomevfssrc"
    gstreamer_sink = "gnomevfssink"
    encode_filename = vfs_encode_filename
    use_gnomevfs = True
    print "  using deprecated gnomevfssrc"
    def set_widget_initial_values(self, glade):

        self.quality_tabs.set_show_tabs(False)

        if self.get_int("same-folder-as-input"):
            w = glade.get_widget("same_folder_as_input")
        else:
            w = glade.get_widget("into_selected_folder")
        w.set_active(True)

        self.target_folder_chooser.set_filename(self.get_string("selected-folder"))
        self.update_selected_folder()

        w = glade.get_widget("create_subfolders")
        w.set_active(self.get_int("create-subfolders"))

        w = glade.get_widget("subfolder_pattern")
        model = w.get_model()
        model.clear()
        for pattern, desc in self.subfolder_patterns:
            iter = model.append()
            model.set(iter, 0, desc)
        w.set_active(self.get_int("subfolder-pattern-index"))

        if self.get_int("replace-messy-chars"):
            w = glade.get_widget("replace_messy_chars")
            w.set_active(True)

        mime_type = self.get_string("output-mime-type")

        # desactivate mp3 output if encoder plugin is not present
        if not gst.element_factory_find("lame"):
            print "LAME GStreamer plugin not found, desactivating MP3 output."
            w = glade.get_widget("output_mime_type_mp3")
            w.set_sensitive(False)
            mime_type = self.defaults["output-mime-type"]

        widget_name = {
            "audio/x-vorbis": "output_mime_type_ogg_vorbis",
            "audio/x-flac": "output_mime_type_flac",
            "audio/x-wav": "output_mime_type_wav",
            "audio/mpeg": "output_mime_type_mp3",
        }.get(mime_type, None)
        if widget_name:
            w = glade.get_widget(widget_name)
            w.set_active(True)
            self.change_mime_type(mime_type)

        w = glade.get_widget("vorbis_quality")
        quality = self.get_float("vorbis-quality")
        quality_setting = {0: 0, 0.2: 1, 0.4: 2, 0.6: 3, 0.8: 4}
        for k, v in quality_setting.iteritems():
            if abs(quality - k) < 0.01:
                w.set_active(v)

        self.mp3_quality = glade.get_widget("mp3_quality")
        self.mp3_mode = glade.get_widget("mp3_mode")
        # w = glade.get_widget("mp3_mode")
        # mode = self.get_int("mp3-mode")
        # w.set_active(mode)
        # self.change_mp3_mode(mode)

        mode = self.get_string("mp3-mode")
        self.change_mp3_mode(mode)

        w = glade.get_widget("basename_pattern")
        model = w.get_model()
        model.clear()
        for pattern, desc in self.basename_patterns:
            iter = model.append()
            model.set(iter, 0, desc)
        w.set_active(self.get_int("name-pattern-index"))

        self.update_example()
Exemplo n.º 33
0
    "pulsesrc",
    "pulsesink",
    "theoraenc",
    "theoradec",
    "lamemp3enc",
    "mp3parse",
    "mad",
    "x264enc",
    "ffenc_mpeg4",
    "ffenc_h263p",
    "celtenc",
    "celtdec",
]

for plugin in gst_plugins:
    if gst.element_factory_find(plugin) is None:
        if plugin in optional_plugins:
            print("Warning: optional plugin " + plugin + " is NOT installed")
        else:
            print("Error: required plugin " + plugin + " is NOT installed")
        missing_plugins.append(plugin)
    else:
        if VERBOSE:
            print(plugin + " installed")

if VERBOSE:
    print("-------------------------------")

if len(missing_plugins) == 0:
    if VERBOSE:
        print("All " + str(len(gst_plugins)) + " necessary plugins installed")
Exemplo n.º 34
0
import gst
import ocv_constants

gstver = gst.version()

if ocv_constants.USE_AUDIORATE is None:
    if gstver[2] > 10:
        ocv_constants.USE_AUDIORATE = True
    else:
        ocv_constants.USE_AUDIORATE = False


if ocv_constants.HAVE_SCHRO is None:
    ocv_constants.HAVE_SCHRO = False
    if gstver[2] > 10:
        schrofac = gst.element_factory_find("schroenc")
        if schrofac is not None:
            if schrofac.check_version(0,10,14):
                print "Schrödinger encoder found, using"
                ocv_constants.HAVE_SCHRO = True
            else:
                print "Old Schrödinger version found, please upgrade"
            
if ocv_constants.HAVE_MATROSKA is None:
    if gst.element_factory_find("matroskamux") is None:
        ocv_constants.HAVE_MATROSKA = False
    else:
        ocv_constants.HAVE_MATROSKA = True
        
if ocv_constants.HAVE_WEBM is None:
    if (ocv_constants.HAVE_MATROSKA is True) and \
Exemplo n.º 35
0
    def check_elements(self, callback, *args):
        """
            Check the elements used in this preset. If they don't exist then
            let GStreamer offer to install them.
            
            @type callback: callable(preset, success, *args)
            @param callback: A method to call when the elements are all 
                             available or installation failed
            @rtype: bool
            @return: True if required elements are available, False otherwise
        """
        elements = [
            # Elements defined in external files
            self.container,
            self.acodec.name,
            self.vcodec.name,
            # Elements used internally
            "decodebin2",
            "videobox",
            "ffmpegcolorspace",
            "videoscale",
            "videorate",
            "ffdeinterlace",
            "audioconvert",
            "audiorate",
            "audioresample",
            "tee",
            "queue",
        ]

        missing = []
        missingdesc = ""
        for element in elements:
            if not gst.element_factory_find(element):
                missing.append(
                    gst.pbutils.missing_element_installer_detail_new(element))
                if missingdesc:
                    missingdesc += ", %s" % element
                else:
                    missingdesc += element

        if missing:
            _log.info("Attempting to install elements: %s" % missingdesc)
            if gst.pbutils.install_plugins_supported():

                def install_done(result, null):
                    if result == gst.pbutils.INSTALL_PLUGINS_INSTALL_IN_PROGRESS:
                        # Ignore start of installer message
                        pass
                    elif result == gst.pbutils.INSTALL_PLUGINS_SUCCESS:
                        callback(self, True, *args)
                    else:
                        _log.error("Unable to install required elements!")
                        callback(self, False, *args)

                context = gst.pbutils.InstallPluginsContext()
                gst.pbutils.install_plugins_async(missing, context,
                                                  install_done, "")
            else:
                _log.error("Installing elements not supported!")
                gobject.idle_add(callback, self, False, *args)
        else:
            gobject.idle_add(callback, self, True, *args)
    if not pad:
        print >> sys.stderr, "Could not retrieve pad '%s'", pad_name
        return

    # Retrieve negotiated caps (or acceptable caps if negotiation is not finished yet)
    caps = pad.get_negotiated_caps()
    if not caps:
        caps = pad.get_caps_reffed()

    # Print and free
    print "Caps for the %s pad:" % pad_name
    print_caps(caps, "      ")


# Create the element factories
source_factory = gst.element_factory_find("audiotestsrc")
sink_factory = gst.element_factory_find("autoaudiosink")
if not source_factory or not sink_factory:
    print >> sys.stderr, "Not all element factories could be created."
    exit(-1)

# Print information about the pad templates of these factories
print_pad_templates_information(source_factory)
print_pad_templates_information(sink_factory)

# Ask the factories to instantiate actual elements
source = source_factory.create("source")
sink = sink_factory.create("sink")

# Create the empty pipeline
pipeline = gst.Pipeline("test-pipeline")
Exemplo n.º 37
0
gst_plugins.sort()

try:
    gst_plugins.remove('sharedvideosink')
except:
    pass

optional_plugins = [
    "dc1394src", "dv1394src", "dvdemux", "dvdec", "alsasrc", "alsasink",
    "pulsesrc", "pulsesink", "theoraenc", "theoradec", "lamemp3enc",
    "mp3parse", "mad", "x264enc", "ffenc_mpeg4", "ffenc_h263p", "celtenc",
    "celtdec"
]

for plugin in gst_plugins:
    if gst.element_factory_find(plugin) is None:
        if plugin in optional_plugins:
            print("Warning: optional plugin " + plugin + " is NOT installed")
        else:
            print("Error: required plugin " + plugin + " is NOT installed")
        missing_plugins.append(plugin)
    else:
        if VERBOSE:
            print(plugin + " installed")

if VERBOSE:
    print("-------------------------------")

if len(missing_plugins) == 0:
    if VERBOSE:
        print("All " + str(len(gst_plugins)) + " necessary plugins installed")
Exemplo n.º 38
0
def create_sbs(out, camera, screen, audio=None, layout='sbs', logger=None):
    """
    Side By Side creator
    
    :param out: output file path
    :param camera: camera video file path
    :param screen: screen video file path 
    :param audio: audio file path or "screen" o "camera" string to re-use files
    """

    pipestr = """
    videomixer name=mix 
        sink_0::xpos=0 sink_0::ypos=0 sink_0::zorder=0
        sink_1::xpos=640 sink_1::ypos=120 sink_1::zorder=1 !
    ffmpegcolorspace name=colorsp_saida ! 
    x264enc quantizer=45 speed-preset=6 profile=1 ! queue ! 
    mp4mux name=mux  ! queue ! filesink location="{OUT}"

    filesrc location="{SCREEN}" ! decodebin2 name=dbscreen ! deinterlace ! 
    aspectratiocrop aspect-ratio={screen_aspect} ! videoscale ! videorate !
    ffmpegcolorspace name=colorsp_screen !
    video/x-raw-yuv,width=640,height=480,framerate=25/1 !
    videobox right=-640 top=-120 bottom=-120 ! queue !
    mix.sink_0 

    filesrc location="{CAMERA}" ! decodebin2 name=dbcamera ! deinterlace ! 
    aspectratiocrop aspect-ratio={camera_aspect} ! videoscale ! videorate !
    ffmpegcolorspace name=colorsp_camera !
    video/x-raw-yuv,width=640,height=480,framerate=25/1,interlaced=false ! queue !
    mix.sink_1 
    """

    pipestr_audio = """
    db{SRC}. ! audioconvert ! queue ! faac bitrate=128000 ! queue ! mux. 
    """

    pipestr_audio_file = """
    filesrc location="{AUDIO}" ! decodebin2 name=dbaudio ! 
    audioconvert ! queue ! faac bitrate=128000 ! queue ! mux.
    """

    if not layout in layouts:
        if logger:
            logger.error('Layout not exists')
        raise IOError, 'Error in SideBySide proccess'

    if not gst.element_factory_find('videomixer2'):
        pipestr = old_pipestr    

    if not camera or not screen:
        if logger:
            logger.error('SideBySide Error: Two videos needed')
        raise IOError, 'Error in SideBySide proccess'

    for track in [camera, screen, audio]:    
        if track and not path.isfile(camera):
            if logger:
                logger.error('SideBySide Error: Not  a valid file %s', track)
            raise IOError, 'Error in SideBySide proccess'

    embeded = False
    if audio:
        pipestr = "".join((pipestr, pipestr_audio_file.format(AUDIO=audio)))
        if logger:
            logger.debug('Audio track detected: %s', audio)
    else:
        if logger:
            logger.debug('Audio embeded')
        embeded = True

    parameters = {'OUT': out, 'SCREEN': screen, 'CAMERA': camera}
    parameters.update(layouts[layout])

    pipeline = gst.parse_launch(pipestr.format(**parameters))
    bus = pipeline.get_bus()

    # connect callback to fetch the audio stream
    if embeded:
        mux = pipeline.get_by_name('mux')    
        dec_camera = pipeline.get_by_name('dbcamera')
        dec_screen = pipeline.get_by_name('dbscreen')    
        dec_camera.connect('pad-added', on_audio_decoded, pipeline, mux)
        dec_screen.connect('pad-added', on_audio_decoded, pipeline, mux)


    pipeline.set_state(gst.STATE_PLAYING)
    msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE, gst.MESSAGE_ERROR | gst.MESSAGE_EOS)
    pipeline.set_state(gst.STATE_NULL)

    if msg.type == gst.MESSAGE_ERROR:
        err, debug = msg.parse_error()
        if logger:
            logger.error('SideBySide Error: %s', err)
        raise IOError, 'Error in SideBySide proccess'

    return True
Exemplo n.º 39
0
        # check profile validity
        if not extension or not pipeline:
            continue
        if not description:
            description = extension
        if description in audio_profiles_dict:
            continue
        # store
        profile = description, extension, pipeline
        audio_profiles_list.append(profile)
        audio_profiles_dict[description] = profile

required_elements = ('decodebin', 'fakesink', 'audioconvert', 'typefind',
                     'audiorate')
for element in required_elements:
    if not gst.element_factory_find(element):
        print("required gstreamer element \'%s\' not found." % element)
        sys.exit(1)

if gst.element_factory_find('giosrc'):
    gstreamer_source = 'giosrc'
    gstreamer_sink = 'giosink'
    encode_filename = vfs_encode_filename
    use_gnomevfs = True
    print('  using gio')
elif gst.element_factory_find('gnomevfssrc'):
    gstreamer_source = 'gnomevfssrc'
    gstreamer_sink = 'gnomevfssink'
    encode_filename = vfs_encode_filename
    use_gnomevfs = True
    print('  using deprecated gnomevfssrc')
Exemplo n.º 40
0
def create_sbs(out, camera, screen, audio=None, layout='sbs', logger=None):
    """
    Side By Side creator
    
    :param out: output file path
    :param camera: camera video file path
    :param screen: screen video file path 
    :param audio: audio file path or "screen" o "camera" string to re-use files
    """

    pipestr = """
    videomixer name=mix 
        sink_0::xpos=0 sink_0::ypos=0 sink_0::zorder=0
        sink_1::xpos=640 sink_1::ypos=120 sink_1::zorder=1 !
    ffmpegcolorspace name=colorsp_saida ! 
    x264enc quantizer=45 speed-preset=6 profile=1 ! queue ! 
    mp4mux name=mux  ! queue ! filesink location="{OUT}"

    filesrc location="{SCREEN}" ! decodebin2 name=dbscreen ! deinterlace ! 
    aspectratiocrop aspect-ratio={screen_aspect} ! videoscale ! videorate !
    ffmpegcolorspace name=colorsp_screen !
    video/x-raw-yuv,width=640,height=480,pixel-aspect-ratio=1/1,framerate=25/1,interlaced=false !
    videobox right=-640 top=-120 bottom=-120 ! queue !
    mix.sink_0 

    filesrc location="{CAMERA}" ! decodebin2 name=dbcamera ! deinterlace ! 
    aspectratiocrop aspect-ratio={camera_aspect} ! videoscale ! videorate !
    ffmpegcolorspace name=colorsp_camera !
    video/x-raw-yuv,width=640,height=480,framerate=25/1,pixel-aspect-ratio=1/1,interlaced=false ! queue !
    mix.sink_1 
    """

    pipestr_audio = """
    db{SRC}. ! audioconvert ! queue ! faac bitrate=128000 ! queue ! mux. 
    """

    pipestr_audio_file = """
    filesrc location="{AUDIO}" ! decodebin2 name=dbaudio ! 
    audioconvert ! queue ! faac bitrate=128000 ! queue ! mux.
    """

    if not layout in layouts:
        if logger:
            logger.error('Layout not exists')
        raise IOError, 'Error in SideBySide proccess'

    if not gst.element_factory_find('videomixer2'):
        pipestr = old_pipestr

    if not camera or not screen:
        if logger:
            logger.error('SideBySide Error: Two videos needed')
        raise IOError, 'Error in SideBySide proccess'

    for track in [camera, screen, audio]:
        if track and not path.isfile(camera):
            if logger:
                logger.error('SideBySide Error: Not  a valid file %s', track)
            raise IOError, 'Error in SideBySide proccess'

    embeded = False
    if audio:
        pipestr = "".join((pipestr, pipestr_audio_file.format(AUDIO=audio)))
        if logger:
            logger.debug('Audio track detected: %s', audio)
    else:
        if logger:
            logger.debug('Audio embeded')
        embeded = True

    parameters = {'OUT': out, 'SCREEN': screen, 'CAMERA': camera}
    parameters.update(layouts[layout])

    pipeline = gst.parse_launch(pipestr.format(**parameters))
    bus = pipeline.get_bus()

    # connect callback to fetch the audio stream
    if embeded:
        mux = pipeline.get_by_name('mux')
        dec_camera = pipeline.get_by_name('dbcamera')
        dec_screen = pipeline.get_by_name('dbscreen')
        dec_camera.connect('pad-added', on_audio_decoded, pipeline, mux)
        dec_screen.connect('pad-added', on_audio_decoded, pipeline, mux)

    pipeline.set_state(gst.STATE_PLAYING)
    msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE,
                                 gst.MESSAGE_ERROR | gst.MESSAGE_EOS)
    pipeline.set_state(gst.STATE_NULL)

    if msg.type == gst.MESSAGE_ERROR:
        err, debug = msg.parse_error()
        if logger:
            logger.error('SideBySide Error: %s', err)
        raise IOError, 'Error in SideBySide proccess'

    return True
Exemplo n.º 41
0
 def has_element(self, kind):
     """
     Returns True if a gstreamer element is available
     """
     return gst.element_factory_find(kind) is not None
Exemplo n.º 42
0
def create_sbs(out, camera, screen, audio=None, layout="sbs", logger=None):
    """
    Side By Side creator
    
    :param out: output file path
    :param camera: camera video file path
    :param screen: screen video file path 
    :param audio: audio file path or "screen" o "camera" string to re-use files
    """

    pipestr = """
    videomixer2 name=mix background=1 
      sink_0::xpos={screen_xpos} sink_0::ypos={screen_ypos} sink_0::zorder={screen_zorder} 
      sink_1::xpos={camera_xpos} sink_1::ypos={camera_ypos} sink_1::zorder={camera_zorder} !
    ffmpegcolorspace name=colorsp_saida ! 
    video/x-raw-yuv, format=(fourcc)I420, width={out_width}, height={out_height}, framerate=25/1 ! 
    x264enc quantizer=45 speed-preset=6 profile=1 ! queue ! 
    mp4mux name=mux  ! queue ! filesink location="{OUT}"
    
    filesrc location="{SCREEN}" ! decodebin2 name=dbscreen ! deinterlace !
    aspectratiocrop aspect-ratio={screen_aspect} ! videoscale ! videorate ! 
    ffmpegcolorspace name=colorsp_screen ! 
    video/x-raw-yuv, format=(fourcc)AYUV, framerate=25/1, width={screen_width}, height={screen_height} ! 
    mix.sink_0 
    
    filesrc location="{CAMERA}" ! decodebin2 name=dbcamera ! deinterlace !
    aspectratiocrop aspect-ratio={camera_aspect} ! videoscale ! videorate ! 
    ffmpegcolorspace name=colorsp_camera ! 
    video/x-raw-yuv, format=(fourcc)AYUV, framerate=25/1, width={camera_width}, height={camera_height} ! 
    mix.sink_1 
    """

    old_pipestr = """
    videomixer name=mix 
        sink_0::xpos=0 sink_0::ypos=0 sink_0::zorder=0
        sink_1::xpos=640 sink_1::ypos=120 sink_1::zorder=1 !
    ffmpegcolorspace name=colorsp_saida ! 
    x264enc quantizer=45 speed-preset=6 profile=1 ! queue ! 
    mp4mux name=mux  ! queue ! filesink location="{OUT}"

    filesrc location="{SCREEN}" !
    queue ! decodebin2 name=dbscreen ! ffmpegcolorspace ! deinterlace ! videoscale ! videorate name=v2 !
    video/x-raw-yuv,width=640,height=480,framerate=25/1 !
    videobox right=-640 top=-120 bottom=-120 ! ffmpegcolorspace !
    mix.sink_0 

    filesrc location="{CAMERA}" !
    queue ! decodebin2 name=dbcamera ! ffmpegcolorspace ! deinterlace ! videoscale ! videorate name=v1 !
    video/x-raw-yuv,width=640,height=480,framerate=25/1,interlaced=false !
    mix.sink_1 
    """

    pipestr_audio = """
    db{SRC}. ! audioconvert ! queue ! faac bitrate=128000 ! queue ! mux. 
    """

    pipestr_audio_file = """
    filesrc location="{AUDIO}" ! decodebin2 name=dbaudio ! 
    audioconvert ! queue ! faac bitrate=128000 ! queue ! mux.
    """

    if not layout in layouts:
        if logger:
            logger.error("Layout not exists")
        raise IOError, "Error in SideBySide proccess"

    if not gst.element_factory_find("videomixer2"):
        pipestr = old_pipestr

    if not camera or not screen:
        if logger:
            logger.error("SideBySide Error: Two videos needed")
        raise IOError, "Error in SideBySide proccess"

    for track in [camera, screen, audio]:
        if track and not path.isfile(camera):
            if logger:
                logger.error("SideBySide Error: Not  a valid file %s", track)
            raise IOError, "Error in SideBySide proccess"

    embeded = False
    if audio:
        pipestr = "".join((pipestr, pipestr_audio_file.format(AUDIO=audio)))
        if logger:
            logger.debug("Audio track detected: %s", audio)
    else:
        if logger:
            logger.debug("Audio embeded")
        embeded = True

    parameters = {"OUT": out, "SCREEN": screen, "CAMERA": camera}
    parameters.update(layouts[layout])

    pipeline = gst.Pipeline("galicaster_sidebyside")
    bus = pipeline.get_bus()

    gst_bin = gst.parse_bin_from_description(pipestr.format(**parameters), False)
    pipeline.add(gst_bin)

    # connect callback to fetch the audio stream
    if embeded:
        mux = pipeline.get_by_name("mux")
        dec_camera = pipeline.get_by_name("dbcamera")
        dec_screen = pipeline.get_by_name("dbscreen")
        dec_camera.connect("pad-added", on_audio_decoded, gst_bin, mux)
        dec_screen.connect("pad-added", on_audio_decoded, gst_bin, mux)

    pipeline.set_state(gst.STATE_PLAYING)
    msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE, gst.MESSAGE_ERROR | gst.MESSAGE_EOS)
    pipeline.set_state(gst.STATE_NULL)

    if msg.type == gst.MESSAGE_ERROR:
        err, debug = msg.parse_error()
        if logger:
            logger.error("SideBySide Error: %s", err)
        raise IOError, "Error in SideBySide proccess"

    return True
Exemplo n.º 43
0
 def check_elements(self, callback, *args):
     """
         Check the elements used in this preset. If they don't exist then
         let GStreamer offer to install them.
         
         @type callback: callable(preset, success, *args)
         @param callback: A method to call when the elements are all 
                          available or installation failed
         @rtype: bool
         @return: True if required elements are available, False otherwise
     """
     elements = [
         # Elements defined in external files
         self.container,
         self.acodec.name,
         self.vcodec.name,
         # Elements used internally
         "decodebin2",
         "videobox",
         "ffmpegcolorspace",
         "videoscale",
         "videorate",
         "ffdeinterlace",
         "audioconvert",
         "audiorate",
         "audioresample",
         "tee",
         "queue",
     ]
     
     missing = []
     missingdesc = ""
     for element in elements:
         if not gst.element_factory_find(element):
             missing.append(gst.pbutils.missing_element_installer_detail_new(element))
             if missingdesc:
                 missingdesc += ", %s" % element
             else:
                 missingdesc += element
     
     if missing:
         _log.info("Attempting to install elements: %s" % missingdesc)
         if gst.pbutils.install_plugins_supported():
             def install_done(result, null):
                 if result == gst.pbutils.INSTALL_PLUGINS_INSTALL_IN_PROGRESS:
                     # Ignore start of installer message
                     pass
                 elif result == gst.pbutils.INSTALL_PLUGINS_SUCCESS:
                     callback(self, True, *args)
                 else:
                     _log.error("Unable to install required elements!")
                     callback(self, False, *args)
         
             context = gst.pbutils.InstallPluginsContext()
             gst.pbutils.install_plugins_async(missing, context,
                                               install_done, "")
         else:
             _log.error("Installing elements not supported!")
             gobject.idle_add(callback, self, False, *args)
     else:
         gobject.idle_add(callback, self, True, *args)
Exemplo n.º 44
0
def enable(exaile):
    for elem in NEEDED_ELEMS:
        if not gst.element_factory_find(elem):
            raise ImportError, "Needed gstreamer element %s missing." % elem
    providers.register("stream_element", ReplaygainVolume)
    providers.register("stream_element", ReplaygainLimiter)
 def make_element(self, elementkind, elementname):
     factory = gst.element_factory_find(elementkind)
     if factory:
         return factory.create(elementname)
     else:
         return None
Exemplo n.º 46
0
    def __init__(self):
        dict.__init__(self)
        self.unique = {}
        defaults = dict(
            outdir       = os.path.abspath("."),
            audiosmp     = 1,  # default to do audio in background...
            bgfile       = "black",

            transition   = None,
            debug        = 0, # 0-2
            pal          = 0,  
            copy         = 0,
            low_quality  = 0,
            high_quality = 0,
            autocrop     = 0,
            ac3          = 1,
            widescreen   = 0,
            border       = 0,  
            width        = 640,
            height       = 480,
            sharpen      = '',
            subtitle_type="dvd",	# or, use empty for default.
            font_dirs    = [ "/usr/share/fonts/","/usr/X11R6/lib/X11/fonts/","/usr/local/share/fonts/"],
            default_fonts= ['n019004l.pfb', # helvetica bold URW fonts
                            'helb____.ttf', # helvetica bold truetype
                            ],
            ## Subtitle
            subtitle_font_size=24,
            subtitle_color="white",
            subtitle_outline_color="black",
            subtitle_location="bottom", # or "top"
            
            ## Title
            title_font_size=48,
            title_font_color='white',  # or use hex "#RRGGBB"
            
            ## top title
            toptitle_font_size=48,
            toptitle_font_color='black', # or use hex "#RRGGBB"
            toptitle_bar_height=125,  # 0 for no 50% white behind text
            toptitle_text_location_x=0.15,
            toptitle_text_location_y=0.25,
            toptitle_text_justification="left",
            
            # bottom title: 
            bottomtitle_font_size=36,
            bottomtitle_font_color="black",  # or use hex "#RRGGBB"
            bottomtitle_bar_height=55,  # 0 for no 50% white behind text
            bottomtitle_text_location_x=0.5,
            bottomtitle_text_location_y=0.65,
            bottomtitle_text_justification="center",

            # annotate
            annotate_size = "8%",
            annotate_font      = "Helvetica-Bold",
            annotate_color     = "#FFFFFF",
            annotate_halign    = "center",
            annotate_valign    = "baseline",
            annotate_vertical  = 0,
            annotate_justification = "center",
            annotate_fontstyle = "BOLD",
            
            theme='default',
            themedir='/opt/sshow/themes',  # LSB/FHS compliant.  see: http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES
            local_themedir="~/.sshow/themes",  # local theme directory
            
            ## not user configurable
            verbosity=0,  # for mpeg2enc and such
            slideshow_name="",
            titletext="",
            write_chap=0,
            subtitle_number=0,
            browse_num=0,
            submenu=0,
            write_chaps=0,
            chapmenu=0,
            browsable=0,
            yuvfirstfile=1,              # tells when to strip yuv headers
            write_last_subtitle=0,
            write_last_subtitle2=0,
            commandline_audiofiles=0,
            nocleanup=0, 
            function_error=0,
            vcd=0,
            svcd=0,
            first_title=1,
            first_image=1,

            mpeg_encoder='ffmpeg', # or mpeg2enc.  I find ffmpeg 2x faster than mpeg2enc
            #mpeg_encoder='mpeg2enc' # or mpeg2enc.  I find ffmpeg 2x faster than mpeg2enc
            output_format='mpeg2', # or flv, mpg, mp4, mp4_ipod.  mpeg2 is default
            #output_format='flv' # or flv, mpg, mp4, mp4_ipod
            ignore_seq_end='-M',

            )
        self.update(defaults)
        
        if gst.element_factory_find("videomixer2") and False:
            self["videomixer"] = "videomixer2"
        else:
            self["videomixer"] = "videomixer"
        print >> sys.stderr, "Could not retrieve pad '%s'", pad_name
        return
  
    # Retrieve negotiated caps (or acceptable caps if negotiation is not finished yet)
    caps = pad.get_negotiated_caps()
    if not caps:
        caps = pad.get_caps_reffed()

    # Print and free 
    print "Caps for the %s pad:"% pad_name
    print_caps(caps, "      ")



# Create the element factories
source_factory = gst.element_factory_find("audiotestsrc")
sink_factory = gst.element_factory_find("autoaudiosink")
if not source_factory or not sink_factory:
    print >> sys.stderr, "Not all element factories could be created."
    exit(-1)

# Print information about the pad templates of these factories 
print_pad_templates_information(source_factory)
print_pad_templates_information(sink_factory)

# Ask the factories to instantiate actual elements
source = source_factory.create("source")
sink = sink_factory.create("sink")

# Create the empty pipeline
pipeline = gst.Pipeline("test-pipeline")