I use gstreamer for playing RTSP stream from IP cameras (like Axis.) I use a command line like this:
gst-launch-0.10 rtspsrc location=rtsp://192.168.0.127/axis-media/media.amp latency=0 ! decodebin ! autovideosink
and it work fine.
I want to control it with a gui in pygtk so I use the gstreamer python bindings. I've wrote this piece of code:
[...]
self.player = gst.Pipeline("player")
source = gst.element_factory_make("rtspsrc", "source")
source.set_property("location", "rtsp://192.168.0.127/axis-media/media.amp")
decoder = gst.element_factory_make("decodebin", "decoder")
sink = gst.element_factory_make("autovideosink", "sink")
self.player.add(source, decoder, sink)
gst.element_link_many(source, decoder, sink)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
bus.connect("message", self.on_message)
bus.connect("sync-message::element", self.on_sync_message)
[...]
But it doesn't work and quit with this message:
gst.element_link_many(source, decoder,sink)
gst.LinkError: failed to link source with decoder
I've also try to improve my CLI with this as I only use h264:
gst-launch-0.10 -v rtspsrc location=rtsp://192.168.0.127/axis-media/media.amp ! rtph264depay ! ffdec_h264 ! xvimagesink
And implement it in my python code like that:
[...]
self.player = gst.Pipeline("player")
source = gst.element_factory_make("rtspsrc", "source")
depay = gst.element_factory_make("rtph264depay", "depay")
decoder = gst.element_factory_make("ffdec_h264", "decoder")
sink = gst.element_factory_make("xvimagesink", "output")
self.player.add(source, depay, decoder, sink)
gst.element_link_many(source, depay, decoder, sink)
[...]
But I got the same error :(
gst.LinkError: failed to link source with depay
There is something wrong between my source (rtspsrc), as it work with decodebin with a filesrc (don't work of course with rtph264depay)
I don't understand why it doesn't work because it work in cli. Any experts of gstreamer who can help me ?
Thanks in advance.
Regards,
I have a "C" implementation of the code you are looking for. I think it should be fairly simple to convert to "Python"
Makefile
UPDATE
Equivalent Java Code
This answer explains why you get a
gst.LinkError
: Gstreamer of python's gst.LinkError problemWith
gst.parse_launch
, you can name elements and then retrieve them to set properties: