issue to play a rtsp video with hardware acceleration in Clutter

Jezequel, Erwan e.jezequel at fondation-parkings.ch
Tue Apr 1 13:13:35 PDT 2014


Thank you for your response.

I did a new code based on something find on internet but it still doesn't
work.

The video doesn't display in the clutter window and I don't understand what
is missing to work.

Here is the code :

from gi.repository import GObject
from gi.repository import Clutter
from gi.repository import ClutterGst
from gi.repository import Gst

class Video(object):
        def __init__ (self, filename):
                self.stage = Clutter.Stage()
                self.stage.set_size(500, 300)
                self.stage.set_color(Clutter.Color.new(0xaa, 0x11, 0xee,
0x00))
                self.stage.set_title('GStreamer Clutter Python - ' +
filename)
                self.stage.connect('key-press-event',
self.on_key_press_event)
                self.stage.connect('destroy', self.on_destroy)
                self.texture = Clutter.Texture.new()



                self.texture.connect('size-change', self.on_size_change)
                self.sink = ClutterGst.VideoSink.new(self.texture)
                self.sink.set_property('sync', True)

                self.pipeline = Gst.Pipeline()

                self.src = Gst.ElementFactory.make("rtspsrc", "source")
                self.src.set_property("location",'rtsp://
192.168.2.11/axis-media/media.amp')
                self.src.set_property("latency",100)

                self.rtph264depay = Gst.ElementFactory.make("rtph264depay",
None)
                self.vaapidecode = Gst.ElementFactory.make("vaapidecode",
None)

                self.pipeline.add(self.src)
                self.pipeline.add(self.rtph264depay)
                self.pipeline.add(self.vaapidecode)
                self.pipeline.add(self.sink)


                self.src.connect("pad-added", self.on_pad)

                self.rtph264depay.link(self.vaapidecode)
                self.vaapidecode.link(self.sink)

                self.bus = self.pipeline.get_bus()
                self.bus.add_signal_watch()
                self.bus.connect('message::eos', self.on_eos)
                self.bus.connect('message::error', self.on_error)

                self.stage.add_actor(self.texture)
                self.pipeline.set_state(Gst.State.PLAYING)

                self.stage.show_all()

        def on_pad(self, rtspsrc, pad):
            print ("on_pad")
            depaySinkPad = self.rtph264depay.get_static_pad('sink')
            pad.link(depaySinkPad)
            print ("on_pad")


        def on_size_change(self, texture, width, height):
                print('on_size_change:')
                stage = texture.get_stage()
                if stage is not None:
                        dx, dy = stage.get_size()
                        texture.set_anchor_point(width/2, height/2)
                        texture.set_position(dx/2, dy/2)

        def on_error(self, bus, msg):
                print('on_error:', msg.parse_error())

        def on_eos(self, bus, msg):
                print('on_eos:', msg)
                self.pipeline.seek_simple(Gst.Format.TIME,
Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, 0)
                self.pipeline.set_state(Gst.State.PAUSED)

        def on_destroy(self, stage, event):
                print('on_destroy:', event)
                self.pipeline.set_state(Gst.State.NULL)
                Clutter.main_quit()

        def on_key_press_event(self, stage, event):
                print('on_key_press_event', event)
                if event.unicode_value:
                        c = event.unicode_value
                        if c in 'qx':
                                self.on_destroy(stage, event)
                                print('quit')
                        elif c in 'pP':
                                self.pipeline.set_state(Gst.State.PAUSED)
                                print('pause')
                        elif c in 'gG':
                                self.pipeline.set_state(Gst.State.PLAYING)
                                print('play')
                        elif c in 'sS':
                                self.pipeline.seek_simple(Gst.Format.TIME,
Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, 0)
                                self.pipeline.set_state(Gst.State.PAUSED)
                                print('stop')


if __name__ == '__main__':
        from sys import argv
        GObject.threads_init()
        Gst.init(argv)
        ClutterGst.init(argv)
        Clutter.init(argv)
        video = Video(*argv[1:])
        Clutter.main()




Thank you

Erwan JEZEQUEL
Service Informatique
079 946 02 91


2014-03-29 9:56 GMT+01:00 Sebastian Dröge <sebastian at centricular.com>:

> On Fr, 2014-03-28 at 12:13 +0100, Jezequel, Erwan wrote:
> > Hello,
> >
> > I am trying to play a rtsp stream in a Clutter window with the following
> > python code but it doesn't work. I think that gstreamer-vaapi works with
> > clutter-gst.
> >
> > Is it supposed to work with gstreamer-vaapi? What should be the correct
> way
> > to do it?
> >
> > [code]
>
> You are never linking the rtspsrc with the depayloader in your code.
> You'll have to connect to the pad-added signal on rtspsrc and link it
> from there once the pad is added.
>
> If that doesn't work yet, please provide more information about how it
> fails and for example a GStreamer debug log.
>
> --
> Sebastian Dröge, Centricular Ltd - http://www.centricular.com
> Expertise, Straight from the Source
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140401/902910aa/attachment.html>


More information about the gstreamer-devel mailing list