hi,
I am a beginner and want to develop some apps using Python and GStreamer. I am using the following pipeline to convert a wav file to mp3. m = gst.parse_launch("filesrc location=~/music.wav ! decodebin ! audioconvert ! lame ! filesink location=~/music.mp3") m.set_state(gst.STATE_PLAYING) # the following prints a traceback # d = m.get_duration(gst.FORMAT_TIME) this creates mp3 file, but it is not complete. I tried time.sleep(seconds) call in the above code. This helped at least write some data to the mp3 file created. for time.sleep() call, I tried different time intervals, but still it doesn't create the file with full data as the original. I don't want to use time.sleep() and want to know if there is a better way to do this. Can anyone help? Also tried the get_duration() method but it throws an error "query failed" |
On Sun, 2010-01-31 at 10:36 -0800, cppb wrote:
> this creates mp3 file, but it is not complete. I tried time.sleep(seconds) > call in the above code. This helped at least write some data to the mp3 file > created. > > for time.sleep() call, I tried different time intervals, but still it > doesn't create the file with full data as the original. > > I don't want to use time.sleep() and want to know if there is a better way > to do this. Can anyone help? > > Also tried the get_duration() method but it throws an error "query failed" You should use the pipeline's bus (GstBus) and wait for either an EOS message or an ERROR message. For progress udpates you could insert a progressreport element (from gst-plugins-good) into the pipeline, somewhere between decodebin and the encoder, and then you'll get regular element messages with the progress (see progressreport element docs). Alternatively you could probably just query decodebin directly for position/duration in TIME format instead of the pipeline (since filesink will most likely drop the query as it doesn't understand TIME format). Cheers -Tim ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by cppb
On 10-01-31 10:36 AM, cppb wrote: > hi, > > I am a beginner and want to develop some apps using Python and GStreamer. > > I am using the following pipeline to convert a wav file to mp3. > > > m = gst.parse_launch("filesrc location=~/music.wav ! decodebin > ! audioconvert ! lame ! filesink location=~/music.mp3") > > m.set_state(gst.STATE_PLAYING) > > # the following prints a traceback > # d = m.get_duration(gst.FORMAT_TIME) > > this creates mp3 file, but it is not complete. I tried time.sleep(seconds) > call in the above code. This helped at least write some data to the mp3 file > created. > > for time.sleep() call, I tried different time intervals, but still it > doesn't create the file with full data as the original. > > I don't want to use time.sleep() and want to know if there is a better way > to do this. Can anyone help? > > Also tried the get_duration() method but it throws an error "query failed" > > http://pygstdocs.berlios.de/ The tutorials should help http://pygstdocs.berlios.de/pygst-tutorial/index.html Example 2.3 is a command line version of a program which plays a file so you should be able to put your gst_launch into the __init__ function and replace the gst.element_factory_make("playbin2",... As you can see from the program you need to run an event loop with glib.Mainloop(), loop.run() and listen for the EOS message which occurs once the input file is consumed with the thread that runs CLI_Main.start(). You could also use gst-launch as a general command line tool and feed it the pipeline definition that you use for gst.parse_launch(). ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |