Python GStreamer src element
Glenn Pierce
glennpierce at gmail.com
Mon Jan 16 07:09:55 PST 2012
I didn't want to high jack the thread from Mahendra about writing a
src plugin in Python. However, I sure it would help him as well.
I am also trying to create an element src in Python. I have found the
following code at
http://lists.freedesktop.org/archives/gstreamer-devel/2011-July/032110.html
This seems to work when placed into a pipeline with a fake sink.
To extend this example and learn more I have decided to try to play a
sine wave. (Ultimately I wan't to pass data from a text to speech
engine)
I cant seem to find any good examples of what's need to be done in do_create.
What I have at the moment is
def do_create(self, offset, length):
data = [str(math.sin(a)*255.0) for a in numpy.arange(0.0,
2*math.pi, 0.01)] ? # How am I meant to populate data ?
buf = gst.Buffer(data)
caps = gst.caps_from_string('audio/x-raw-float, rate=44100,
channels=1, width=8')
buf.set_caps(caps)
buf.timestamp = 0 * gst.SECOND
buf.duration = 4 * gst.SECOND
return gst.FLOW_OK, buf
I basically need to know how I can populate the Buffer object with
audio data as a string.
Everything I try results in
error: Internal data flow error.
I am using to with the following pipeline to playback.
'acapelasrc ! audioconvert ! audioresample ! autoaudiosink'
Any pointers would be greatly appreciated.
Thanks
More information about the gstreamer-devel
mailing list