Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python bindings for gstreamer: how to import typelib

I was building gstreamer latest version on my raspberry pi. I wanted to have python bindings, hence I installed gobject-introspection-1.0 and pygobject-3.18.2 before compiling the gstreamer and its plugins.

At the end of the build of gstreamer and all of its plugins, I see these files:

pi@raspberrypi:~/kurento $ ls -ltr /usr/local/lib/girepository-1.0
total 580
-rw-r--r-- 1 root staff 214076 Mar 28 19:28 Gst-1.5.typelib
-rw-r--r-- 1 root staff  43712 Mar 28 19:28 GstBase-1.5.typelib
-rw-r--r-- 1 root staff   6500 Mar 28 19:28 GstController-1.5.typelib
-rw-r--r-- 1 root staff   6272 Mar 28 19:28 GstNet-1.5.typelib
-rw-r--r-- 1 root staff  13116 Mar 28 19:29 GstCheck-1.5.typelib
-rw-r--r-- 1 root staff  14460 Mar 28 20:23 GstTag-1.5.typelib
-rw-r--r-- 1 root staff   2508 Mar 28 20:23 GstFft-1.5.typelib
-rw-r--r-- 1 root staff  27460 Mar 28 20:23 GstRtp-1.5.typelib
-rw-r--r-- 1 root staff  24160 Mar 28 20:23 GstSdp-1.5.typelib
-rw-r--r-- 1 root staff  32856 Mar 28 20:23 GstRtsp-1.5.typelib
-rw-r--r-- 1 root staff  75268 Mar 28 20:23 GstVideo-1.5.typelib
-rw-r--r-- 1 root staff  46800 Mar 28 20:24 GstAudio-1.5.typelib
-rw-r--r-- 1 root staff  25764 Mar 28 20:24 GstPbutils-1.5.typelib
-rw-r--r-- 1 root staff   5732 Mar 28 20:24 GstApp-1.5.typelib
-rw-r--r-- 1 root staff   1876 Mar 28 20:24 GstAllocators-1.5.typelib
-rw-r--r-- 1 root staff  17736 Mar 28 22:37 Nice-0.1.typelib

Then I compiled gst-python-1.7.1 and then I see the following at appropriate location:

pi@raspberrypi:~/kurento $ ls -l /usr/local/lib/python2.7/site-packages/gi/overrides/
total 640
-rw-r--r-- 1 root staff 15002 Mar 28 18:11 Gdk.py
-rw-r--r-- 1 root staff 14996 Mar 28 18:11 Gdk.pyc
-rw-r--r-- 1 root staff 14996 Mar 28 18:11 Gdk.pyo
-rwxr-xr-x 1 root staff  1141 Mar 29 22:19 _gi_gst.la
-rwxr-xr-x 1 root staff 56124 Mar 29 22:19 _gi_gst.so
-rw-r--r-- 1 root staff  2240 Mar 28 18:11 GIMarshallingTests.py
-rw-r--r-- 1 root staff  2428 Mar 28 18:11 GIMarshallingTests.pyc
-rw-r--r-- 1 root staff  2428 Mar 28 18:11 GIMarshallingTests.pyo
-rw-r--r-- 1 root staff  8147 Mar 28 18:11 Gio.py
-rw-r--r-- 1 root staff  8176 Mar 28 18:11 Gio.pyc
-rw-r--r-- 1 root staff  8075 Mar 28 18:11 Gio.pyo
-rw-r--r-- 1 root staff 33233 Mar 28 18:11 GLib.py
-rw-r--r-- 1 root staff 31701 Mar 28 18:11 GLib.pyc
-rw-r--r-- 1 root staff 31656 Mar 28 18:11 GLib.pyo
-rw-r--r-- 1 root staff 26255 Mar 28 18:11 GObject.py
-rw-r--r-- 1 root staff 23401 Mar 28 18:11 GObject.pyc
-rw-r--r-- 1 root staff 23401 Mar 28 18:11 GObject.pyo
-rw-r--r-- 1 root staff  2785 Mar 29 22:19 GstPbutils.py
-rw-r--r-- 1 root staff  2584 Mar 29 22:19 GstPbutils.pyc
-rw-r--r-- 1 root staff  2584 Mar 29 22:19 GstPbutils.pyo
-rw-r--r-- 1 root staff 11570 Mar 29 22:19 Gst.py
-rw-r--r-- 1 root staff 16602 Mar 29 22:19 Gst.pyc
-rw-r--r-- 1 root staff 16602 Mar 29 22:19 Gst.pyo
-rw-r--r-- 1 root staff 56202 Mar 28 18:11 Gtk.py
-rw-r--r-- 1 root staff 64602 Mar 28 18:11 Gtk.pyc
-rw-r--r-- 1 root staff 64602 Mar 28 18:11 Gtk.pyo
-rw-r--r-- 1 root staff 12820 Mar 28 18:11 __init__.py
-rw-r--r-- 1 root staff 13128 Mar 28 18:11 __init__.pyc
-rw-r--r-- 1 root staff 13070 Mar 28 18:11 __init__.pyo
-rw-r--r-- 1 root staff  1705 Mar 28 18:11 keysyms.py
-rw-r--r-- 1 root staff  1137 Mar 28 18:11 keysyms.pyc
-rw-r--r-- 1 root staff  1137 Mar 28 18:11 keysyms.pyo
-rw-r--r-- 1 root staff  1679 Mar 28 18:11 Pango.py
-rw-r--r-- 1 root staff  1727 Mar 28 18:11 Pango.pyc
-rw-r--r-- 1 root staff  1727 Mar 28 18:11 Pango.pyo

With this setup, I expect to see Gst module being loaded from gi repository.

>>> sys.path
['/usr/local/lib/python2.7/site-packages', '', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-arm-linux-gnueabihf', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
>>> import gi
>>> from gi.repository import Gst
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name Gst
>>> gi.require_version('Gst','1.5')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 102, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available
>>> 

But this is not happening. Please, your help is needed to import the Gst modules into python. Has anyone come across similar situation?

Thanks!

like image 856
Chetan Naik Avatar asked Sep 06 '25 03:09

Chetan Naik


1 Answers

GObject instrospection need type descriptions located at /usr/lib/girepository-1.0

In my case I have:

/usr/lib/girepository-1.0$ ls Gst*1.5*

Gst-1.5.typelib            GstFft-1.5.typelib        GstRtp-1.5.typelib
GstAllocators-1.5.typelib  GstGL-1.5.typelib         GstRtsp-1.5.typelib
GstApp-1.5.typelib         GstInsertBin-1.5.typelib  GstSdp-1.5.typelib
GstAudio-1.5.typelib       GstMpegts-1.5.typelib     GstTag-1.5.typelib
GstBase-1.5.typelib        GstNet-1.5.typelib        GstVideo-1.5.typelib
GstCheck-1.5.typelib       GstPbutils-1.5.typelib
GstController-1.5.typelib  GstPlayer-1.5.typelib

Try installing typelib files there.

I don't have any Gst*.py files installed, with the types description is enough.

Edit

Defining GI_TYPELIB_PATH pointing it to the directory containing the typelib files, in your case /usr/local/lib/girepository-1.5, also solves the problem.

like image 102
santoscadenas Avatar answered Sep 08 '25 00:09

santoscadenas