[Wolves] Python GStreamer problem

Richard Barker rtbarker2004 at gmail.com
Sat Mar 17 17:27:19 GMT 2007


Here's an interesting one, possibly o/t for this list, but I'll be cheeky
and ask anyway. :)

I'm writing a meditation timer program in Python, it waits for 'n' minutes
then plays an ogg encoded bell sound.  Everything is great, got the GUI and
it plays the sound via a GStreamer playbin.

My problem is that there is a slight delay between the end of the time
period and the sound playing as playbin loads it.  So I think I need to read
the file into memory during my program initialisation and play it from there
rather than the disk.

I was playing with the code below, but when I try to add the buffer into the
pipeline with "gst.element_link_many(buffer, decode)", it complains it's not
a gstreamer object.

My question is, can anyone give me any guidance on how to pre-buffer /
pre-decode the ogg sound, or what I'm doing wrong with this buffer please?




import os
import pygst
import gst

class playit:
    def main(self):
        size = os.path.getsize("./test.ogg")
        file = open("./test.ogg","r")
        # Construct the GStreamer pipeline
        player = gst.Pipeline("testplayer")
        #Buffer source
        buffer = gst.buffer_new_and_alloc(size)
        buffer = file.read

        #Binary decoder
        decode = gst.element_factory_make("decodebin", "decode")
        decode.connect("new-decoded-pad", self.OnDynamicPad)

        #Audio converter
        converter = gst.element_factory_make("audioconvert","converter")
        #ALSA Sink
        sink = gst.element_factory_make("alsasink","sink")
        #Link them up
        gst.element_link_many(buffer, decode)
        gst.element_link_many(converter, sink)

    def OnDynamicPad(self, dbin, pad, islast):

if __name__ == "__main__":
    gsttest = playit()



Visit my sites, I don't bite unless you're in fishnets!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/wolves/attachments/20070317/47c80a50/attachment.html

More information about the Wolves mailing list