Cannot load python gstreamer elements
Asked Answered
H

4

6

I'm following a guide at https://mathieuduponchelle.github.io/2018-02-01-Python-Elements.html?gi-language=undefined to create a sample gstreamer element in Python. However, I can't get GStreamer to load it. I've been fiddling with the GST_PLUGIN_PATH but I can't get my python files to be found. I can get GStreamer to find compiled .so elements, but the python elements seem to evade the plugin loader.

I've installed gstreamer1.0, pygobject, and gst-python to the best of my ability onto Debian 9.8, Linux fe34e822e54e 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64:

apt install gstreamer1.0-tools
apt install python3-gst-1.0 python-gst-1.0  # install python bindings for gstreamer
apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0  # Install PyGObject as per https://pygobject.readthedocs.io/en/latest/getting_started.html#ubuntu-getting-started

I root in /tmp/my_gtest:

$ ls
python
$ ls python/
srcelement.py
$ GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD gst-inspect-1.0 audiotestsrc_py
No such element or plugin 'audiotestsrc_py'
$ GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD GST_DEBUG=4 gst-inspect-1.0 --gst-plugin-path=/tmp/g/ audiotestsrc_py
0:00:00.000117317   900 0x560506a39a00 INFO                GST_INIT gst.c:510:init_pre: Initializing GStreamer Core Library version 1.10.4
0:00:00.000236545   900 0x560506a39a00 INFO                GST_INIT gst.c:511:init_pre: Using library installed in /usr/lib/x86_64-linux-gnu
0:00:00.000264897   900 0x560506a39a00 INFO                GST_INIT gst.c:522:init_pre: Linux fe34e822e54e 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64
0:00:00.000422525   900 0x560506a39a00 INFO                GST_INIT gst.c:427:add_path_func: Adding plugin path: "/tmp/my_gtest/", will scan later
0:00:00.001049692   900 0x560506a39a00 INFO                GST_INIT gstmessage.c:126:_priv_gst_message_initialize: init messages
0:00:00.002382651   900 0x560506a39a00 INFO                GST_INIT gstcontext.c:83:_priv_gst_context_initialize: init contexts
0:00:00.002634936   900 0x560506a39a00 INFO      GST_PLUGIN_LOADING gstplugin.c:316:_priv_gst_plugin_initialize: registering 0 static plugins
0:00:00.002687971   900 0x560506a39a00 INFO      GST_PLUGIN_LOADING gstplugin.c:224:gst_plugin_register_static: registered static plugin "staticelements"
0:00:00.002695054   900 0x560506a39a00 INFO      GST_PLUGIN_LOADING gstplugin.c:226:gst_plugin_register_static: added static plugin "staticelements", result: 1
0:00:00.002703860   900 0x560506a39a00 INFO            GST_REGISTRY gstregistry.c:1738:ensure_current_registry: reading registry cache: /root/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.007377882   900 0x560506a39a00 INFO            GST_REGISTRY gstregistrybinary.c:619:priv_gst_registry_binary_read_cache: loaded /root/.cache/gstreamer-1.0/registry.x86_64.bin in 0.004664 seconds
0:00:00.007421588   900 0x560506a39a00 INFO            GST_REGISTRY gstregistry.c:1594:scan_and_update_registry: Validating plugins from registry cache: /root/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.007427719   900 0x560506a39a00 INFO            GST_REGISTRY gstregistry.c:1606:scan_and_update_registry: Scanning plugin path: "/tmp/my_gtest/"
0:00:00.008249182   900 0x560506a39a00 INFO            GST_REGISTRY gstregistry.c:1696:scan_and_update_registry: Registry cache has not changed
0:00:00.008255509   900 0x560506a39a00 INFO            GST_REGISTRY gstregistry.c:1773:ensure_current_registry: registry reading and updating done, result = 1
0:00:00.008277874   900 0x560506a39a00 INFO                GST_INIT gst.c:720:init_post: GLib runtime version: 2.50.3
0:00:00.008282666   900 0x560506a39a00 INFO                GST_INIT gst.c:722:init_post: GLib headers version: 2.50.3
0:00:00.008286452   900 0x560506a39a00 INFO                GST_INIT gst.c:723:init_post: initialized GStreamer successfully
No such element or plugin 'audiotestsrc_py'

A hunch is that gst-python isn't properly installed, or my gstreamer wasn't compiled properly (can't trust those packages?). However, the python binding seems fine, as when I run python3:

>>> import gi
>>> gi.require_version('Gst', '1.0')
>>> from gi.repository import GObject, Gst
>>> GObject.threads_init()
>>> Gst.init(None)
>>> Gst.ElementFactory.make("tee")
<__gi__.GstTee object at 0x7f438eef1318 (GstTee at 0x564f28de8000)>
>>> Gst.ElementFactory.make("audiotestsrc_py")
>>> 

You see the same behaviour where the audiotestsrc_py can't be found.

Not sure what to try next, probably going to have to develop the gst plugin in C.

Humfrey answered 22/5, 2019 at 21:10 Comment(0)
C
5

Yes, I hit this same problem on a clean gstreamer install (inside a docker container.) To fix, I cloned gst-python and built it:

cd /home/ml/gst-python
export PYTHON=/usr/bin/python3
./autogen.sh --disable-gtk-doc --noconfigure
./configure --prefix=/usr --with-libpython-dir=/usr/lib/x86_64-linux-gnu
make
sudo make install

echo "check install"
export GST_PLUGIN_PATH=/usr/lib/gstreamer-1.0
gst-inspect-1.0 python

I then put the python identity_py plugin in a work area under plugins/python and tested:

cd /home/work/gstreamer

# all python plugins are under $PWD/plugins/python
export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD/plugins

gst-inspect-1.0 identity_py
GST_DEBUG=python:4 gst-launch-1.0 fakesrc num-buffers=10 ! identity_py ! fakesink

Quite the little rabbit hole! BTW, I think I could have used the appsink plugin to achieve my purpose.

Coincidentally answered 19/3, 2020 at 23:7 Comment(0)
Z
2

Maybe you have the same issue as me: https://bugs.launchpad.net/ubuntu/+source/gst-python1.0/+bug/1739966

I'm working around by compiling from source.

Zemstvo answered 3/9, 2019 at 6:16 Comment(1)
Possible. I remember trying to compile from source, but on debian perhaps this bug affected me. Thanks, I'll approve this if I ever get around to working on the python binding again.Humfrey
S
0

You might be missing the python plugin. You can check it with gst-inspect-1.0 python. If it's missing, you can install it with sudo apt install gstreamer1.0-python3-plugin-loader. After that, you should be able to import your custom Python plugin by placing your files into a /plugins/python folder and adding the path to GST_PLUGIN_PATH:

GST_PLUGIN_PATH=$GST_PLUGIN_PATH:/plugins gst-inspect-1.0 mypluginame
Selia answered 25/2, 2022 at 21:31 Comment(0)
S
0

In most recent tutorials (which are already old), generally it's only written to install gst-python and it will work, but now (in ubuntu at least), that does not install the python plugin.

The answer from user1315621 is working for me! Installing gstreamer1.0-python3-plugin-loader is the solution

Stancil answered 5/5, 2023 at 8:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.