How to install Gstreamer Python Bindings

3 min. read |

Development for Gstreamer could be quite challenging at the beginning. But there is a lifeboard, – Gstreamer Python Bindings. With Python it is much easier to understand basic Gstreamer concepts and at the same time to speed up applications development.

Requirements

  • Ubuntu 18
  • Python 3.6

Guide

Personal experience

Gstreamer is written on pure C. I worked with C/C++ for almost 5 years. But at first it was still quite difficult to use it and prototype video analytics applications within short deadlines. And almost all logic for such applications often is written in Python using OpenCV, Tensorflow. But with Gstreamer Bindings for Python it was much easier to build applications using advantages of Gstreamer’s flexibility and Python’s simplicity. Now I could hide any image processing in Gstreamer pipeline and for analytics pipeline just use decoded RGB buffer.

Dockerfile

Checkout Dockerfile to build Docker Image for Ubuntu 18 and Gstreamer Python Binding.

Manual

First, Install Gstreamer on Ubuntu

In addition we need to install dev package for gstreamer

Then, install Python specific packages.

Also install additional packages required to build Gstreamer from sources

Let’s install packages for Python GObject, GObject Introspection required to make Gstreamer friends with Python.

Now system is ready to build gst-python package from repository.

Building gst-python from sources

First, create a test virtual environment to check installation

After all, install pip-requirements. Detailed requirements for Python GObject installation

Checkout Python GObject API References. This resource is going to be main source of Gstreamer API for Python.

Gst-Python API Check

Now check that essential imports are working in python

Gst-Python Plugin Check

Download gst-plugin-check.py and execute next command

If while running previous commands you got any mistakes, then proceed with next steps.

Let’s build gst-python from sources. This allows to use the latest gstreamer python bindings and align it with pre-installed gstreamer version.

Automated way:

  • Gstreamer Version
  • libpython-dir (location of libpython*m.so
  • Prefix (Python Library Path)

Repeat GstPython API Check.

Hope everything works as expected. Finally, in case of any errors, mistakes or problems leave comments down here. I’d be happy to find out solution with you 😉

Add a Comment

Your email address will not be published. Required fields are marked *