注意:你的任何gstreamer操作都要在外部环境运行,不能在conda等虚拟环境!
否则报错:
WARNING: erroneous pipeline: no element "x264enc"
等等,各种 no element !!!
先看看是不是这个问题!!!
此时你去捜来艘去,可能会有安装pyobject的操作,安装姿势如下文。
安装pyobject时报错:
../meson.build:31:9: ERROR: Dependency 'girepository-2.0' is required but not found.
试了各种办法无果,根本不能直接装girepository-2.0,最后找到官网,
https://pygobject.gnome.org/getting_started.html#ubuntu-getting-started
按照教程一步步走就行了(那个py脚本不用管,安装成功pyobject就好了),我用的清华镜像没问题:
nstalling the system provided PyGObject:
-
Open a terminal
-
Execute
sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0 -
Change the directory to where your
hello.pyscript can be found (e.g.cd Desktop) -
Run
python3 hello.py
Installing from PyPI with pip:
-
Open a terminal and enter your virtual environment
-
Execute
sudo apt install libgirepository-2.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-4.0to install the build dependencies and GTK -
Execute
pip3 install pycairoto build and install Pycairo -
Execute
pip3 install PyGObjectto build and install PyGObject -
Change the working directory to where your
hello.pyscript can be found -
Run
python3 hello.py
如果上述例子过不去,各种报错,考虑是否是用了conda或者其他虚拟环境,似乎pyobjtect只能在非虚拟环境用?也许可以用,但直接用不行,懒得折腾了。
conda环境的话, conda deactivate,官方例子可以跑通。
4686

被折叠的 条评论
为什么被折叠?



