gstreamer python bindings for windows
This is a bit late, but hopefully it will help.
The easiest way to use GStreamer 1.0 is to download the latest version from: http://sourceforge.net/projects/pygobjectwin32/files/
This will install Python (2.7 or 3.3) modules and, optionally, GStreamer with plugins.
However, if you already have GStreamer 0.10 SDK (from docs.gstreamer.com/display/GstSDK/Home) and old installation of GStreamer 1.0 somewhere, there might be some problems with running Gstreamer 0.10 Python programs, like ImportError: DLL load failed etc. Here's my detailed setup for everything:
Installation of Gst 0.10 SDK and Python modules
- Install SDK from docs.gstreamer.com/display/GstSDK/Installing+on+Windows. Check and set environment variables
GSTREAMER_SDK_ROOT_X86=..your sdk dir
GST_PLUGIN_PATH=%GSTREAMER_SDK_ROOT_X86%\lib\gstreamer-0.10
Path=%GSTREAMER_SDK_ROOT_X86%\bin;%GSTREAMER_SDK_ROOT_X86%\lib;%Path% - Install pygtk-all-in-one-2.24.2.win32-py2.7 from ftp.gnome.org/pub/GNOME/binaries/win32/
- In your Python site-packages dir create file pygst.pth. Put following lines, which should point to GSt 0.10 Python modules directories:
..your %GSTREAMER_SDK_ROOT_X86% \lib\python2.7\site-packages
..your %GSTREAMER_SDK_ROOT_X86% \lib\python2.7\site-packages\gst-0.10 - After that, pydoc should be able to find documentation for pygst, gst, etc. Also, intellisense in Python tools for Visual studio should work too (after rebuilding Completion DB and restarting VS)
Installation of Gst 1.0 and Python modules
- Install GStreamer 1.0 from gstreamer.freedesktop.org/data/pkg/windows/. Check environment:
GSTREAMER_1_0_ROOT_X86=..Gst 1.0 installation dir
GST_PLUGIN_PATH_1_0=%GSTREAMER_1_0_ROOT_X86%\lib\gstreamer-1.0\
Path=%GSTREAMER_1_0_ROOT_X86%\bin;%GSTREAMER_1_0_ROOT_X86%\lib;%Path% - Install pygi-aio-3.10.2-win32_rev14-setup from the above Sourceforge link. Include Gstreamer and plugins in the installation.
- Create file gi.pth:
%GSTREAMER_1_0_ROOT_X86%\bin
%GSTREAMER_1_0_ROOT_X86%\lib - I removed everything from the site-packages/gnome directory except:
libgirepository-1.0-1
libpyglib-gi-2.0-python27-0
lib directory with the .typelib files
and a few simple examples seem to work fine. - Intellisense in VS doesn't seem to work for imports from gi.repository.
You may test your installation like this:
python2 -c "import gi; gi.require_version('Gst', '1.0'); from gi.repository import Gst; Gst.init(None); pipeline = Gst.parse_launch('playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm'); pipeline.set_state(Gst.State.PLAYING); bus = pipeline.get_bus();msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)"
Edit: If you use both GStreamer0.10 and GStreamer1.0 it's better to create a separate virtual environment for GStreamer0.10 and put .pth files in its site-packages directory. See my comment below.
HTH, Tom
Step 1: Windows 8.1 64-bit
Step 2: Download and Install Python
C:\>wget https://www.python.org/ftp/python/2.7.9/python-2.7.9.amd64.msi
C:\>./python-2.7.9.amd64.msi
C:\>cd C:\Python27
C:\>pwd
C:\Python27
Step 3: Download install Python bindings for Gstreamer 1.0
C:\>wget http://sourceforge.net/projects/pygobjectwin32/files/pygi-aio-3.14.0_rev14-setup.exe
C:\>unzip "pygi-aio-3.14.0_rev14-setup.exe"
C:\>whereis_unzipped "pygi-aio-3.14.0_rev14-setup.exe"
C:\pygi
C:\>./c:\pygi\setup.exe
Step 4: Run this code
C:\>C:\Python27\python.exe -c "import gi; gi.require_version('Gst', '1.0'); from gi.repository import Gst; Gst.init(None); pipeline = Gst.parse_launch('playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm'); pipeline.set_state(Gst.State.PLAYING); bus = pipeline.get_bus();msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)"
Step 5: You have to wait 10 minutes, to see a result similar to following. Because it takes time for some reason
The installer from http://sourceforge.net/projects/pygobjectwin32/files/ should works for the test case that Tom gave. Try to match which plugins installed by pygi installer with the one from official gstreamer.
The installer try to be a "portable and private" installation for each python without registry/environmen vars changes.
My note about the runtime dlls, it's recommended not to mixing the runtime cause the one from pygi is made specifically for python a.k.a linked to msvcrt preferred by python, and use stat() convention that used by python too. If a public api such glib's stat() use different convention than other dll then a runtime mixing could lead to a silent crash. Other than that it may works fine though.