Playback of a video stream is slow under GTK

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Playback of a video stream is slow under GTK

pisymbol .
Pipeline:
filesrc location=\"{}\" ! matroskademux name=demux demux.video_{} ! h264parse ! avdec_h264 ! videoconvert name=videoconvert

Obviously 'demux_video_{}' is calculated at run-time (usually 0 or 1).

When I use this within a GTK application, i.e. I connect 'videoconvert' connect to 'gtksink' the video looks like it is in slow motion.

Has anyone seen this before?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

Mathieu Duponchelle
I've never seen that, but a test case would probably be helpful :) Also, you should always use
queues after demuxers.

On 7/29/19 9:56 PM, pisymbol . wrote:
Pipeline:
filesrc location=\"{}\" ! matroskademux name=demux demux.video_{} ! h264parse ! avdec_h264 ! videoconvert name=videoconvert

Obviously 'demux_video_{}' is calculated at run-time (usually 0 or 1).

When I use this within a GTK application, i.e. I connect 'videoconvert' connect to 'gtksink' the video looks like it is in slow motion.

Has anyone seen this before?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

pisymbol .


On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
I've never seen that, but a test case would probably be helpful :)

Not sure what exactly to share:

Here is the gist of the code:

class GstPlayerWdiget(Gtk.Box):
....
       self.play_pipeline = Gst.Pipeline()
       factory = self.play_pipeline.get_factory()
       gtksink = Gst.ElementFactory.make('gtksink', None)
       gtksink.set_property("sync", False)

       self.ghostpad = Gst.GhostPad.new("sink", self.vc.get_static_pad('src'))
       self.play_bin.add_pad(self.ghostpad)

       self.play_pipeline.add(gtksink)
       self.play_pipeline.add(self.play_bin)
       self.play_bin.link(gtksink)
       self.pack_start(gtksink.props.widget, True, True, 0)

       # We automatically start playing as soon as we are drawn on the screen
       bus = self.play_pipeline.get_bus()
       bus.add_signal_watch()
       bus.enable_sync_message_emission()
       bus.connect("sync-message::element", self.on_sync_message)
       self.play_pipeline.set_state(Gst.State.PLAYING)
       gtksink.props.widget.show_all()
 
Also, you should always use
queues after demuxers.


 Threading them out always going to be faster?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

Nicolas Dufresne-5


Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :


On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
I've never seen that, but a test case would probably be helpful :)

Not sure what exactly to share:

Here is the gist of the code:

class GstPlayerWdiget(Gtk.Box):
....
       self.play_pipeline = Gst.Pipeline()
       factory = self.play_pipeline.get_factory()
       gtksink = Gst.ElementFactory.make('gtksink', None)
       gtksink.set_property("sync", False)

By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.

If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).

       self.ghostpad = Gst.GhostPad.new("sink", self.vc.get_static_pad('src'))
       self.play_bin.add_pad(self.ghostpad)

       self.play_pipeline.add(gtksink)
       self.play_pipeline.add(self.play_bin)
       self.play_bin.link(gtksink)
       self.pack_start(gtksink.props.widget, True, True, 0)

       # We automatically start playing as soon as we are drawn on the screen
       bus = self.play_pipeline.get_bus()
       bus.add_signal_watch()
       bus.enable_sync_message_emission()
       bus.connect("sync-message::element", self.on_sync_message)
       self.play_pipeline.set_state(Gst.State.PLAYING)
       gtksink.props.widget.show_all()
 
Also, you should always use
queues after demuxers.


 Threading them out always going to be faster?

-aps
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

pisymbol .


On Mon, Jul 29, 2019 at 8:00 PM Nicolas Dufresne <[hidden email]> wrote:


Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :


On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
I've never seen that, but a test case would probably be helpful :)

Not sure what exactly to share:

Here is the gist of the code:

class GstPlayerWdiget(Gtk.Box):
....
       self.play_pipeline = Gst.Pipeline()
       factory = self.play_pipeline.get_factory()
       gtksink = Gst.ElementFactory.make('gtksink', None)
       gtksink.set_property("sync", False)

By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.

I originally had it off. Let me set sync to True again.


If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).

Why does it play normally using gst-launch-1.0 then?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

Nicolas Dufresne-5


Le lun. 29 juill. 2019 20 h 56, pisymbol . <[hidden email]> a écrit :


On Mon, Jul 29, 2019 at 8:00 PM Nicolas Dufresne <[hidden email]> wrote:


Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :


On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
I've never seen that, but a test case would probably be helpful :)

Not sure what exactly to share:

Here is the gist of the code:

class GstPlayerWdiget(Gtk.Box):
....
       self.play_pipeline = Gst.Pipeline()
       factory = self.play_pipeline.get_factory()
       gtksink = Gst.ElementFactory.make('gtksink', None)
       gtksink.set_property("sync", False)

By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.

I originally had it off. Let me set sync to True again.


If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).

Why does it play normally using gst-launch-1.0 then?

Simpler gtk / Cairo render ? Use a profiler if you need to know, I was quite please with sysprof lately.


-aps
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

pisymbol .
In reply to this post by Nicolas Dufresne-5


On Mon, Jul 29, 2019 at 8:00 PM Nicolas Dufresne <[hidden email]> wrote:


Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :


On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
I've never seen that, but a test case would probably be helpful :)

Not sure what exactly to share:

Here is the gist of the code:

class GstPlayerWdiget(Gtk.Box):
....
       self.play_pipeline = Gst.Pipeline()
       factory = self.play_pipeline.get_factory()
       gtksink = Gst.ElementFactory.make('gtksink', None)
       gtksink.set_property("sync", False)

By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.

If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).

Nicholas, pardon my ignorance, but how does configuring videoconvert use more than one thread?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

Nicolas Dufresne-5
Le mardi 30 juillet 2019 à 09:45 -0400, pisymbol . a écrit :

>
>
> On Mon, Jul 29, 2019 at 8:00 PM Nicolas Dufresne <[hidden email]> wrote:
> >
> > Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :
> > >
> > > On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
> > > > I've never seen that, but a test case would probably be helpful :)
> > > >
> > >
> > > Not sure what exactly to share:
> > >
> > > Here is the gist of the code:
> > >
> > > class GstPlayerWdiget(Gtk.Box):
> > > ....
> > >        self.play_pipeline = Gst.Pipeline()
> > >        factory = self.play_pipeline.get_factory()
> > >        gtksink = Gst.ElementFactory.make('gtksink', None)
> > >        gtksink.set_property("sync", False)
> >
> > By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.
> >
> > If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).
> >
>
> Nicholas, pardon my ignorance, but how does configuring videoconvert use more than one thread?

There is a property called n-threads, 0 mean as many as there is CPU,
and then any other value will try and use that specific amount of
threads. In python that would be:

  converter.props.n_threads = N
or
  converter.set_property("n-threads", N)

>
> -aps
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

pisymbol .


On Wed, Jul 31, 2019 at 8:09 AM Nicolas Dufresne <[hidden email]> wrote:
Le mardi 30 juillet 2019 à 09:45 -0400, pisymbol . a écrit :
>
>
> On Mon, Jul 29, 2019 at 8:00 PM Nicolas Dufresne <[hidden email]> wrote:
> >
> > Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :
> > >
> > > On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
> > > > I've never seen that, but a test case would probably be helpful :)
> > > >
> > >
> > > Not sure what exactly to share:
> > >
> > > Here is the gist of the code:
> > >
> > > class GstPlayerWdiget(Gtk.Box):
> > > ....
> > >        self.play_pipeline = Gst.Pipeline()
> > >        factory = self.play_pipeline.get_factory()
> > >        gtksink = Gst.ElementFactory.make('gtksink', None)
> > >        gtksink.set_property("sync", False)
> >
> > By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.
> >
> > If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).
> >
>
> Nicholas, pardon my ignorance, but how does configuring videoconvert use more than one thread?

There is a property called n-threads, 0 mean as many as there is CPU,
and then any other value will try and use that specific amount of
threads. In python that would be:

  converter.props.n_threads = N
or
  converter.set_property("n-threads", N)

Is this on newer releases? I ask because now I see it in the online doc but not using `gst-inspect-1.0 videoconvert` as an element property?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

Mathieu Duponchelle
The property was added in February 2017, so as far as I can tell you need at least 1.12,
possibly 1.14

On 7/31/19 6:21 PM, pisymbol . wrote:


On Wed, Jul 31, 2019 at 8:09 AM Nicolas Dufresne <[hidden email]> wrote:
Le mardi 30 juillet 2019 à 09:45 -0400, pisymbol . a écrit :
>
>
> On Mon, Jul 29, 2019 at 8:00 PM Nicolas Dufresne <[hidden email]> wrote:
> >
> > Le lun. 29 juill. 2019 19 h 56, pisymbol . <[hidden email]> a écrit :
> > >
> > > On Mon, Jul 29, 2019 at 5:51 PM Mathieu Duponchelle <[hidden email]> wrote:
> > > > I've never seen that, but a test case would probably be helpful :)
> > > >
> > >
> > > Not sure what exactly to share:
> > >
> > > Here is the gist of the code:
> > >
> > > class GstPlayerWdiget(Gtk.Box):
> > > ....
> > >        self.play_pipeline = Gst.Pipeline()
> > >        factory = self.play_pipeline.get_factory()
> > >        gtksink = Gst.ElementFactory.make('gtksink', None)
> > >        gtksink.set_property("sync", False)
> >
> > By disabling the sync, you ask GStreamer to play all frames, even when real-time isn't possible due to cpu limitation. So slow motion on this entirely software pipeline is what you have asked GStreamer.
> >
> > If you have multiple cores, consider configuring videoconvert to use more then one thread, or add queues at well chosen places (e.g. between decoder and converter).
> >
>
> Nicholas, pardon my ignorance, but how does configuring videoconvert use more than one thread?

There is a property called n-threads, 0 mean as many as there is CPU,
and then any other value will try and use that specific amount of
threads. In python that would be:

  converter.props.n_threads = N
or
  converter.set_property("n-threads", N)

Is this on newer releases? I ask because now I see it in the online doc but not using `gst-inspect-1.0 videoconvert` as an element property?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Playback of a video stream is slow under GTK

pisymbol .


On Wed, Jul 31, 2019 at 12:48 PM Mathieu Duponchelle <[hidden email]> wrote:
The property was added in February 2017, so as far as I can tell you need at least 1.12,
possibly 1.14

Thanks! Apologies for missing it in the doc (I was relying on gst-inspect-1.0).

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel