Best practice for pipeline to display video in Gtk4 app

I’ve developed an application in Python/Gtk4 for our vacation pictures and movies. The built-in video for Gtk4 is too limited, so I’m using gstreamer. This is on Manjaro Linux test branch so all Gtk and Gst packages are very recent.

I’ve done a very simple pipeline, basically connecting playbin3 straight to gtk4paintablesink embedded in a Gtk Picture… This is all working well. I was just wondering if this is an appropriate way to use things, letting the sink and Gtk take care of scaling etc.

Should i be putting things like videoconvert or other components into the pipeline to handle things?

Here’s the class where I set up the pipeline.

class GtkSink(Gtk.Picture):
    def __init__(self):
        super().__init__()
        # noinspection PyArgumentList,PyTypeChecker
        self.player = Gst.ElementFactory.make("playbin3", None)
        player_factory = self.player.get_factory()
        # noinspection SpellCheckingInspection
        video_sink: Gst.ChildProxy = player_factory.make('gtk4paintablesink', 'videosink')
        self.player.set_property("video-sink", video_sink)
        audio_sink: Gst.ChildProxy = player_factory.make('pulsesink', 'audiosink')
        # noinspection PyArgumentList
        role = Gst.Structure.new_from_string('props,media.role=video')
        audio_sink.set_property('stream-properties', role)
        role.free()
        self.player.set_property("audio-sink", audio_sink)
        paintable = video_sink.get_property('paintable')
        self.set_paintable(paintable)

Cheers,
Pat

Usually we wrap it I to glsinkbin, it will allow texture rendering (and dmanuf offloads recently). This will help avoid the software convert that playbin adds for you. It will enable more pixel formats too.

Thanks for the information. I’ll read up and try that. Please could you let me know what you wrap in glsinkbin? It sounds like you’re suggesting avoiding playbin?

No, create a glsinkbin, set its sink property to the GTK4 sink and then set playbin’s video-sink to the glsinkbin.

Thanks. I read up after the first response and ended up doing that. Thank you for the pointer though.

There’s a Python example in the repository btw. That might be helpful here.

Thanks. That’s a very useful example for carrying out the plumbing. I’d found the C equivalent, but couldn’t find the Python one. My original question was more about what to plumb rather than how, and that example completes the thread!