gst-launch error handling

Florian Lindner mailinglists at xgm.de
Wed Dec 14 05:49:53 PST 2011


2011/12/14 Tim-Philipp Müller <t.i.m at zen.co.uk>:
> On Wed, 2011-12-14 at 13:08 +0100, Florian Lindner wrote:
>
>> I feared that answer. I have already searched the web for a minimal
>> python example. The "official" examples at
>> http://pygstdocs.berlios.de/pygst-tutorial/index.html all involve a
>> lot of GTK code for creating windows etc. I simply find no starting
>> point with the python API. If I really need that mass of code (like in
>> the aforementioned examples) for just duplicating that gst-launch
>> call, I would rather go with executing gst-launch and parse the output
>> for errors.
>
> You don't need that much code (you didn't say whether it's ok to block
> while waiting for the pipeline or finish or error out).
>
> In the simplest case you can just do something like (pseudo-code):
>
>  pipeline = gst.parse_launch("...")
>  bus = pipeline.get_bus()
>  msg=bus.timed_pop(gst.MESSSAGE_EOS | gst.MESSAGE_ERROR,
> gst.CLOCK_TIME_NONE)
>  if msg.type == gst.MESSAGE_ERROR:
>    print "Error!"
>  else:
>    print "Done"

Ok, based on your code I created:


import gst

pipe_desc = "filesrc location=accept.flac ! decodebin ! audioconvert !
lamemp3enc ! xingmux ! id3v2mux ! filesink location=out.mp3"

pipeline = gst.parse_launch(pipe_desc)
print pipeline
bus = pipeline.get_bus()
print bus
msg = bus.poll(gst.MESSAGE_EOS | gst.MESSAGE_ERROR, -1)
print msg

timed_pop seems to be existing somewhere, but I was unable to find
documentation on it.
The code blocks forever at bus.poll and creates no output file:

florian at horus ~/testconv % python2 gsttest.py
** Message: pygobject_register_sinkfunc is deprecated (GstObject)
/GstPipeline:pipeline0 (gst.Pipeline)
/GstBus:bus2 (gst.Bus)

gst-launch $pipe_desc works as intended.

Any ideas?

Thanks!


More information about the gstreamer-devel mailing list