0

This simple Gstreamer app fails using the python API

import pgi
pgi.require_version('Gst', '1.0')
from pgi.repository import Gst, GLib
import traceback

Gst.init([])

pipeline = Gst.Pipeline()
src = Gst.ElementFactory.make('videotestsrc', 'src')
sink = Gst.ElementFactory.make('autovideosink', 'sink')
pipeline.add(src)
pipeline.add(sink)
src.link(sink)
src.set_property("pattern", 0)

pipeline.set_state(Gst.State.PLAYING)

with

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/Documents/mythic-projects/OKR_2019Q2/gstreamer_pipeline.py in <module>
     12 pipeline.add(sink)
     13 src.link(sink)
---> 14 src.set_property("pattern", 0)
     15
     16 pipeline.set_state(Gst.State.PLAYING)

~/Documents/mythic-projects/OKR_2019Q2/venv/lib/python3.6/site-packages/pgi/obj.py in set_property(self, name, value)
     73
     74         if not hasattr(self.props, name):
---> 75             raise TypeError("Unknown property: %r" % name)
     76         setattr(self.props, name, value)
     77

TypeError: Unknown property: 'pattern'

I can confirm the command line operation works fine:

gst-launch-1.0 videotestsrc pattern=snow ! autovideosink

But the API seems to be different from the documentation and tutorials. This is true for any .set_property() operation.

e.g. http://lifestyletransfer.com/how-to-launch-gstreamer-pipeline-in-python/

I'm running on Mac OSX, python3.6, and I installed gstreamer as outlined by here: Installing Gstreamer-1.0 on Mac OS X Mavericks (I also tried installing from the .dmg, but the results are the same)

Ben
  • 6,986
  • 6
  • 44
  • 71

1 Answers1

0

The tutorial uses import gi not import pgi. That could make a difference.

The PGI page https://github.com/pygobject/pgi says it is unmaintained and one should use PyGObject instead too.

Florian Zwoch
  • 6,764
  • 2
  • 12
  • 21
  • humm I was lead astray https://stackoverflow.com/questions/44213921/python-3-installing-gi-package-with-pip – Ben Apr 19 '19 at 13:11