【问题标题】:Cannot load python gstreamer elements无法加载 python gstreamer 元素
【发布时间】:2019-05-22 21:10:43
【问题描述】:

我正在遵循https://mathieuduponchelle.github.io/2018-02-01-Python-Elements.html?gi-language=undefined 的指南以在 Python 中创建示例 gstreamer 元素。但是,我无法让 GStreamer 加载它。我一直在摆弄GST_PLUGIN_PATH,但找不到我的 python 文件。我可以让 GStreamer 找到已编译的 .so 元素,但 python 元素似乎避开了插件加载器。

我已尽我所能在 Debian 9.8 上安装了 gstreamer1.0、pygobject 和 gst-python,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

我扎根于/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'

预感是 gst-python 没有正确安装,或者我的 gstreamer 没有正确编译(不能信任那些包?)。但是,python 绑定似乎很好,就像我运行 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")
>>> 

在找不到 audiotestsrc_py 的情况下,您会看到相同的行为。

不确定接下来要尝试什么,可能必须用 C 语言开发 gst 插件。

【问题讨论】:

    标签: python plugins gstreamer


    【解决方案1】:

    是的,我在干净的 gstreamer 安装(在 docker 容器内)遇到了同样的问题。为了解决这个问题,我克隆了 gst-python 并构建了它:

    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
    

    然后我将pythonidentity_py插件放在plugins/python下的工作区并测试:

    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
    

    真是个小兔子洞!顺便说一句,我想我可以使用appsink 插件来实现我的目的。

    【讨论】:

      【解决方案2】:

      也许你和我有同样的问题:https://bugs.launchpad.net/ubuntu/+source/gst-python1.0/+bug/1739966

      我正在通过从源代码编译来解决问题。

      【讨论】:

      • 可能的。我记得尝试从源代码编译,但在 debian 上,这个错误可能影响了我。谢谢,如果我有时间再次处理 python 绑定,我会批准这个。
      【解决方案3】:

      您可能缺少python 插件。您可以使用gst-inspect-1.0 python 进行检查。如果它丢失,您可以使用sudo apt install gstreamer1.0-python3-plugin-loader 安装它。之后,您应该能够通过将文件放入 /plugins/python 文件夹并将路径添加到 GST_PLUGIN_PATH 来导入自定义 Python 插件:

      GST_PLUGIN_PATH=$GST_PLUGIN_PATH:/plugins gst-inspect-1.0 mypluginame
      

      【讨论】:

        猜你喜欢
        • 2012-09-20
        • 2022-08-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-05
        • 1970-01-01
        • 2018-09-13
        • 1970-01-01
        相关资源
        最近更新 更多