Hello,
I plan to use gst-launch in a simple python script that mass converts flac to mp3 files. I would use it like that: gst-launch-0.10 filesrc location=accept.flac ! decodebin ! audioconvert ! lamemp3enc ! xingmux ! id3v2mux ! filesink location=out.mp3 How can I do error handling if any of the pipeline modules produce an error? e.g. I've modified the flac file to be invalid, that produces that output: florian@horus ~/testconv % gst-launch-0.10 filesrc location=accept.flac ! decodebin ! audioconvert ! lamemp3enc ! xingmux ! id3v2mux ! filesink location=out.mp3 Setting pipeline to PAUSED ... Pipeline is PREROLLING ... Redistribute latency... Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0: Could not decode stream. Additional debug info: gstflacdec.c(666): gst_flac_dec_error_cb (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstFlacDec:flacdec0: unknown error (3) Execution ended after 11017569 ns. Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... Returncode is 0. How to detect an error? Parse output for ERROR? I know that gst-launch is not intended for applications, but in my simple case using the python interface with the event loop and all that stuff seems to be a bit too much. Or have I mistaken the API docs? Thanks, Florian _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
On Wed, 2011-12-14 at 12:42 +0100, Florian Lindner wrote:
> I plan to use gst-launch in a simple python script that mass converts > flac to mp3 files. I would use it like that: > > gst-launch-0.10 filesrc location=accept.flac ! decodebin ! > audioconvert ! lamemp3enc ! xingmux ! id3v2mux ! filesink > location=out.mp3 > > How can I do error handling if any of the pipeline modules produce an > error? e.g. I've modified the flac file to be invalid, that produces > that output: > ... > Returncode is 0. How to detect an error? Parse output for ERROR? > > I know that gst-launch is not intended for applications, but in my > simple case using the python interface with the event loop and all > that stuff seems to be a bit too much. Or have I mistaken the API > docs? If you have a python script, you should probably just use the gstreamer python bindings and use pipeline = gst.parse_launch("....") and then check for error message on the pipeline's bus (or EOS), either in a blocking way (timed_pop) or asynchronously (running a main loop). Cheers -Tim _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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. Regards, Florian 2011/12/14 Tim-Philipp Müller <[hidden email]>: > On Wed, 2011-12-14 at 12:42 +0100, Florian Lindner wrote: > >> I plan to use gst-launch in a simple python script that mass converts >> flac to mp3 files. I would use it like that: >> >> gst-launch-0.10 filesrc location=accept.flac ! decodebin ! >> audioconvert ! lamemp3enc ! xingmux ! id3v2mux ! filesink >> location=out.mp3 >> >> How can I do error handling if any of the pipeline modules produce an >> error? e.g. I've modified the flac file to be invalid, that produces >> that output: >> ... >> Returncode is 0. How to detect an error? Parse output for ERROR? >> >> I know that gst-launch is not intended for applications, but in my >> simple case using the python interface with the event loop and all >> that stuff seems to be a bit too much. Or have I mistaken the API >> docs? > > If you have a python script, you should probably just use the gstreamer > python bindings and use pipeline = gst.parse_launch("....") and then > check for error message on the pipeline's bus (or EOS), either in a > blocking way (timed_pop) or asynchronously (running a main loop). > > Cheers > -Tim > > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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" Feel free to submit a patch to fix up the exit code regardless, but calling gst-launch like that in an application is just a bad idea. Cheers -Tim > > 2011/12/14 Tim-Philipp Müller <[hidden email]>: > > On Wed, 2011-12-14 at 12:42 +0100, Florian Lindner wrote: > > > >> I plan to use gst-launch in a simple python script that mass converts > >> flac to mp3 files. I would use it like that: > >> > >> gst-launch-0.10 filesrc location=accept.flac ! decodebin ! > >> audioconvert ! lamemp3enc ! xingmux ! id3v2mux ! filesink > >> location=out.mp3 > >> > >> How can I do error handling if any of the pipeline modules produce an > >> error? e.g. I've modified the flac file to be invalid, that produces > >> that output: > >> ... > >> Returncode is 0. How to detect an error? Parse output for ERROR? > >> > >> I know that gst-launch is not intended for applications, but in my > >> simple case using the python interface with the event loop and all > >> that stuff seems to be a bit too much. Or have I mistaken the API > >> docs? > > > > If you have a python script, you should probably just use the gstreamer > > python bindings and use pipeline = gst.parse_launch("....") and then > > check for error message on the pipeline's bus (or EOS), either in a > > blocking way (timed_pop) or asynchronously (running a main loop). > > > > Cheers > > -Tim > > > > _______________________________________________ > > gstreamer-devel mailing list > > [hidden email] > > http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
2011/12/14 Tim-Philipp Müller <[hidden email]>:
> 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@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! _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
On Wed, 2011-12-14 at 14:49 +0100, Florian Lindner wrote:
> 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: You'll also have to set the pipeline to playing state before doing the poll(), with pipeline.set_state(gst.STATE_PLAYING) or so. Cheers -Tim _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Ok, it works this way now, Thanks!
One more question: On a successful convert I get a None Message: (Pdb) msg <gst.Message (none) from pipeline0 at 0x18e2080> Stupid question... but how do I actually test for that message? Florian 2011/12/14 Tim-Philipp Müller <[hidden email]>: > On Wed, 2011-12-14 at 14:49 +0100, Florian Lindner wrote: > >> 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: > > You'll also have to set the pipeline to playing state before doing the > poll(), with pipeline.set_state(gst.STATE_PLAYING) or so. > > Cheers > -Tim > > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |