[gst-devel] converting between audio formats using GStreamer

Ron McOuat rmcouat at smartt.com
Sun Jan 31 20:03:19 CET 2010



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"
>
>    
Check out this URL for Python info

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().





More information about the gstreamer-devel mailing list