Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 865519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:39:09+00:00 2026-05-15T09:39:09+00:00

I am wiring a gstreamer application with Python. And I get a LinkError with

  • 0

I am wiring a gstreamer application with Python. And I get a LinkError with following code:

import pygst
pygst.require('0.10')
import gst

import pygtk
pygtk.require('2.0')
import gtk

# this is very important, without this, callbacks from gstreamer thread
# will messed our program up
gtk.gdk.threads_init()

def main():
    pipeline = gst.Pipeline('pipleline')

    filesrc = gst.element_factory_make("filesrc", "filesrc")
    filesrc.set_property('location', 'C:/a.mp3')

    decode = gst.element_factory_make("decodebin", "decode")

    convert = gst.element_factory_make('audioconvert', 'convert')

    sink = gst.element_factory_make("autoaudiosink", "sink")

    pipeline.add(filesrc, decode, convert, sink)
    gst.element_link_many(filesrc, decode, convert, sink)

    pipeline.set_state(gst.STATE_PLAYING)

    gtk.main()

main()

And the error:

ImportError: could not import gio
Traceback (most recent call last):
  File "H:\workspace\ggg\src\test2.py", line 37, in <module>
    main()
  File "H:\workspace\ggg\src\test2.py", line 31, in main
    gst.element_link_many(filesrc, decode, convert, sink)
gst.LinkError: failed to link decode with convert

It is very strange, with same pipeline, but built with parse_launch, it works. Here is the code:

import pygst
pygst.require('0.10')
import gst

import pygtk
pygtk.require('2.0')
import gtk

# this is very important, without this, callbacks from gstreamer thread
# will messed our program up
gtk.gdk.threads_init()

def main():
    player = gst.parse_launch('filesrc location=C:/a.mp3 ! decodebin ! audioconvert ! autoaudiosink') 
    player.set_state(gst.STATE_PLAYING)
    gtk.main()

main()

Here comes the question, why the manual one failed, but the parsed one success? What’s wrong with that? How can I fix it?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:39:09+00:00Added an answer on May 15, 2026 at 9:39 am

    your problem is here:

    gst.element_link_many(filesrc, decode, convert, sink)
    

    the reason is that not all elements have simple, static inputs and outputs. at this point in your program, your decodebin does not have any source pads (that is: no outputs).

    a pad is like a nipple – it’s an input / output to an element. pads can appear, disappear or just sit there. there are three classes of pads: static pads (the easiest and what you would expect), request pads (that appear only when you ask for them) and sometimes pads (that appear only when the element wants to make them appear). the outputs of decodebin are sometimes pads.

    if you inspect the output of gst-inspect decodebin, you can see this for yourself:

    Pad Templates:
      SINK template: 'sink'
        Availability: Always
        Capabilities:
          ANY
    
      SRC template: 'src%d'
        Availability: Sometimes
        Capabilities:
          ANY
    

    at line 26 of your program, you can’t link decode to anything, because it doesn’t have any source pads to link with. source pads on a decodebin appear only as the input stream is decoded: this doesn’t happen instantaneously. any number of source pads may appear (e.g one for an audio stream, two for a video stream with audio, none for an un-decodable stream).

    you need to wait until the pads are created, and then link them. decodebin emits a signal, “new-decoded-pad” to tell you when this happens (this is also documented in gst-inspect decodebin). you must connect a callback function to this signal, and link your decode and audioconvert in the callback. here is your corrected code:

    #!/usr/bin/python
    
    import pygst
    pygst.require('0.10')
    import gst
    
    import pygtk
    pygtk.require('2.0')
    import gtk
    
    # this is very important, without this, callbacks from gstreamer thread
    # will messed our program up
    gtk.gdk.threads_init()
    
    def on_new_decoded_pad(dbin, pad, islast):
        decode = pad.get_parent()
        pipeline = decode.get_parent()
        convert = pipeline.get_by_name('convert')
        decode.link(convert)
        pipeline.set_state(gst.STATE_PLAYING)
        print "linked!"
    
    def main():
        pipeline = gst.Pipeline('pipleline')
    
        filesrc = gst.element_factory_make("filesrc", "filesrc")
        filesrc.set_property('location', 'C:/a.mp3')
    
        decode = gst.element_factory_make("decodebin", "decode")
    
        convert = gst.element_factory_make('audioconvert', 'convert')
    
        sink = gst.element_factory_make("autoaudiosink", "sink")
    
        pipeline.add(filesrc, decode, convert, sink)
        gst.element_link_many(filesrc, decode)
        gst.element_link_many(convert, sink)
    
        decode.connect("new-decoded-pad", on_new_decoded_pad)
    
        pipeline.set_state(gst.STATE_PAUSED)
    
        gtk.main()
    
    main()
    

    gst.parse_launch works because it takes care of all these niggly details for you. there is also the high level element playbin which automatically creates and links a decodebin internally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following code wiring a NHibernate ISession in Autofac for a ASP.NET
Problems with wiring up datepicker The code for partial view @model System.DateTime @Html.TextBox(, Model.ToString(dd/MM/yy),
I am wiring up my first SubSonic 3 application (in an ASP.NET MVC 1.0
I'm wiring the following method to my document.ready function. However, the myAutoCompleteURL.aspx URL is
I want to implement something similar to this: http://www.kjetilk.com/2011/10/auto-wiring-eventaggregator.html . But instead of using
My problem is not wiring up DependencyProperties in a UserControl . This is not
We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager
I am using PicoContainer to do the wiring of the classes of my application.
I'm using this kind of wiring for my MVC and I want to test
I have the following code: UINavigationController localNavigationController = [[[NSBundle mainBundle] loadNibNamed:@CustomView owner:self options:nil] objectAtIndex:0];

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.