Hi ; I’ve been working on a video player, and made two prototypes:
- A Gtk3 / Gstreamer / Gdk.DrawingArea implementation
- A Gtk4 / GtkVideo Gtk.MediaStream implementation
And found out that the GtkVideo player is choking on a lot of video files, when the Gstreamer one is playing basically whatever I throw at him, so I’m going to go with it, but I want to do it in Gtk4.
Also from my trials, the Gst approach is way more flexible in terms of precise control of the video : Seeking, subtitles, audio tracks, widgets, etc.
My question is : Is this even possible? I see that Gtk.DrawingArea is still part of Gtk4 (and not flagged as deprecated) but maybe the new Paintable interface changes the way of doing this.
Also the way that the GSTreamer video draws to the DrawingArea seems to be very Gtk3-specific:
video_window = Gtk.DrawingArea.new()
video_window.connect("realize", self.on_realize)
video_window.connect("draw", self.on_draw)
# this function is called when the GUI toolkit creates the physical window
# that will hold the video
# at this point we can retrieve its handler and pass it to GStreamer
# through the XOverlay interface
def on_realize(self, widget):
window = widget.get_window()
window_handle = window.get_xid()
(…)
# pass it to playbin, which implements XOverlay and will forward
# it to the video sink
self.playbin.set_window_handle(window_handle)
But are those methods and elements available in Gtk4? I though I’d ask here is this approach is even portable to Gtk4/Adw, or if I should look right away for a new system for draw/painting my video stream to a Gtk4 widget?
To be clear, this is really my question : How would one go today about creating a Gst-based video player in Gtk4 (Adw.Application)?
I already verified that the required libs are available :
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
gi.require_version('Gst', '1.0')
gi.require_version('GdkX11', '4.0')
gi.require_version('GstVideo', '1.0')
from gi.repository import Gtk, Gio, Adw, Gdk, GLib, Gst, GdkX11, GstVideo
Also, I’d like my application to be ready for Wayland, and all of this seems really XOrg specific…? I guess that’s another question: Is there a way to make a Gst-based Gtk4 video player that works on Wayland?