[gst-devel] works with gst-launch but not in python

Rohan rohan at perzonae.com
Tue Sep 29 12:04:01 CEST 2009


Hi all,

I am trying to stream video and audio over the network.  I have the
video working so far thanks to pointing out my little blunder the
other day.

But audio is not working, and this time I have remembered to add the
src to the pipeline.  The gst-launch sequence works perfectly, so I am
obviously missing another obvious thing.

These are the gst-launch commands that play happily together:

sender:

gst-launch-010 audiotestsrc ! queue ! audioconvert ! speexenc ! \
tcpserversink host=127.0.0.1 port=5001

receiver:

gst-launch-0.10 tcpclientsrc host=127.0.0.1 port=5001 ! speexdec ! \
queue ! alsasink sync=false

And here are the python scripts that are just reiterating this in
python, but it is not working

-------------------------------------------------------------------
#!/bin/env python

# sound_receiver.py

#gst-launch-0.10 tcpclientsrc host=127.0.0.1 port=5001 ! speexdec ! queue ! 
alsasink sync=false

import gobject
import pygst
pygst.require("0.10")
import gst

class server(object):
	def __init__(self):
		pipe = gst.Pipeline("receive")
		src = gst.element_factory_make("tcpclientsrc")
		src.set_property("host", '127.0.0.1')
		src.set_property("port", 5001)

		pipe.add(src)

		sbin = self.buildsound()
		pipe.add(sbin)
		src.link(sbin)

		pipe.set_state(gst.STATE_PLAYING )

	def buildsound(self):
		bin = gst.Bin("sound")
		speexdec = gst.element_factory_make("speexdec")
		queue = gst.element_factory_make('queue')
		soundsink = gst.element_factory_make("autoaudiosink")
		bin.add(speexdec, queue, soundsink)
		gst.element_link_many(speexdec, queue, soundsink)
		
		binsink = gst.GhostPad("sbinsink", speexdec.get_pad("sink"))
		bin.add_pad(binsink)
		return bin
		
if __name__ == "__main__":
	server()
	loop = gobject.MainLoop()
	loop.run()

----------------------------------------------------------------------
#!/bin/env python

# sound_sender.py

# gst-launch-010 audiotestsrc ! queue ! audioconvert ! speexenc ! tcpserversink 
host=127.0.0.1 port=5001

import gobject
import pygst
pygst.require("0.10")
import gst

class client(object):
	def __init__(self):
		pipe = gst.Pipeline("sound")
		src = gst.element_factory_make("audiotestsrc")
		sbin = self.build_sound()
		
		pipe.add(src, sbin)
		src.link(sbin)

		pipe.set_state(gst.STATE_PLAYING)

	def build_sound(self):
		bin = gst.Bin("sbin")
		queue = gst.element_factory_make("queue")
		decode = gst.element_factory_make("decodebin")
		convert = gst.element_factory_make("audioconvert")
		speexenc = gst.element_factory_make("speexenc")
		sink = gst.element_factory_make("tcpserversink")
		sink.set_property("host", '127.0.0.1')
		sink.set_property("port", 5001)
		bin.add(queue, decode, convert, speexenc, sink)
		gst.element_link_many(queue, convert, speexenc, sink)

		binsink = gst.GhostPad("sbinsink", queue.get_pad("sink"))
		bin.add_pad(binsink)
		return bin
		


if __name__ == '__main__':
	client()
	loop = gobject.MainLoop()
	loop.run()
--------------------------------------------------------------------

I have noticed that with the gst-launch sequences you must have the
sound sender running before starting the sound receiver, but starting
the python scripts in either order makes no difference to the outcome:
no sound, and no error output.

Thanks in advance for any help, this has had me stumped for a while
now,

Rohan




More information about the gstreamer-devel mailing list