Show video on Windows

Marwin Schmitt M.R.Schmitt at
Mon Dec 1 13:43:08 PST 2014


I had the same problem and reported the bug to the gnome bugtracker quite a while ago .. but since it is still not fixed, I used a dirty hack, accessing the gdk_win32_window_get_handle via ctypes (and it took me forever no experience with that).

Here is the code:

def on_sync_message(bus, message):
        if message.get_structure() is None:
        if GstVideo.is_video_overlay_prepare_window_handle_message(message):#                                    
            #get the gdk window and the corresponding c gpointer
            drawingareawnd = drawingarea.get_property("window")            
            if not drawingareawnd.has_native():#ensure_native should be called before, e.g. on realize
                print("Error - drawing does not have a native window - this window will freeze when moved or resized")
            ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
            ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object]
            drawingarea_gpointer = ctypes.pythonapi.PyCapsule_GetPointer(drawingareawnd.__gpointer__, None)

            #get the win32 handle
            gdkdll = ctypes.CDLL ("libgdk-3-0.dll")
            hnd = gdkdll.gdk_win32_window_get_handle(drawingarea_gpointer)
            #pass it to the sink


----- Original Message -----
From: "Manuel" <manuel at>
To: gstreamer-devel at
Sent: Friday, September 26, 2014 7:48:32 PM
Subject: Show video on Windows

Hi all,

in my program I use PyGObject/PyGI and GStreamer to show a video in my
GUI. The video is shown in a Gtk.DrawingArea and therefore I need to get
it's window-handle in the realize-signal-handler. On Linux I get that
handle using:

But how do I get the handle on Windows?

I searched on the internet but found only examples for PyGtk using
window.handle which does not work using PyGI.

The GStreamer documentation provides an example which uses the
GDK_WINDOW_HWND macro to get the handle. This macro uses AFAIK
gdk_win32_drawable_get_handle. But how to do it in Python using PyGI?

Best regards
gstreamer-devel mailing list
gstreamer-devel at

More information about the gstreamer-devel mailing list