python-2.7 - GStreamer Python 错误 : 'gst.ElementNotFoundError: videoconvert'

标签 python-2.7 ubuntu gstreamer

我正在尝试创建一个简单的 GStreamer 管道,它可以拍摄视频、裁剪并播放它,与 python 。

通过终端,这条管道运行良好:

gst-launch-1.0 filesrc location='/home/inbarcha/Desktop/gstreamer_interface/U2One.mp4' ! decodebin ! videoconvert ! videocrop top=150 left=150 right=4 bottom=0 ! ximagesink

但是,当我尝试使用这个 python 代码时:
import pygst
pygst.require('0.10')
import gst

import pygtk
pygtk.require('2.0')
import gtk

class CropVideo:
    def __init__(self, video_path, top_crop, left_crop, right_crop, bottom_crop):
        self.pipeline = gst.Pipeline('crop_video')

        self.filesrc = gst.element_factory_make('filesrc', 'file_src')
        self.filesrc.set_property('location', video_path)
        self.pipeline.add(self.filesrc)

        self.decodebin = gst.element_factory_make('decodebin', 'decode')
        self.pipeline.add(self.decodebin)
        self.filesrc.link(self.decodebin)

        self.videoconvert = gst.element_factory_make('videoconvert', 'convert')
        self.pipeline.add(self.videoconvert)
        self.decodebin.link(self.videoconvert)

        self.videocrop = gst.element_factory_make('videocrop', 'crop')
        self.videocrop.set_property('top', top_crop)
        self.videocrop.set_property('left', left_crop)
        self.videocrop.set_property('right', right_crop)
        self.videocrop.set_property('bottom', bottom_crop)
        self.pipeline.add(self.videocrop)
        self.videoconvert.link(self.videocrop)

        self.ximagesink = gst.element_factory_make('ximagesink', 'output_video')
        self.pipeline.add(self.ximagesink)
        self.videocrop.link(self.ximagesink)


if __name__ == "__main__":
    start = CropVideo('/home/inbarcha/Desktop/gstreamer_interface/U2One.mp4', 150, 150, 4, 0)
    gtk.main()

我得到的错误是:
Traceback (most recent call last):
  File "/home/inbarcha/Desktop/gstreamer_interface/src/gstreamer_crop_video.py", line 41, in <module>
    start = CropVideo('/home/inbarcha/Desktop/gstreamer_interface/U2One.mp4', 150, 150, 4, 0)
  File "/home/inbarcha/Desktop/gstreamer_interface/src/gstreamer_crop_video.py", line 13, in __init__
    self.videoconvert = gst.element_factory_make('videoconvert', 'convert')
gst.ElementNotFoundError: videoconvert

我无法弄清楚问题所在。
我试图让python使用gst-1.0而不是gst-0.10,但是虽然我确实在python2.7中下载了带有“sudo apt-get update/sudo apt-get install python-gst-1.0”的python包dist-packages 目录我只看到“gst-0.10”,我似乎找不到gst-1.0的安装目录。

我觉得我错过了什么,答案就在我面前。

任何帮助将不胜感激。

Ubuntu 版本:14.04
Python版本:2.7

最佳答案

看起来 videoconvert元素在 Gstreamer 0.10 中不可用。根据此文档 https://gstreamer.freedesktop.org/documentation/application-development/appendix/porting-1-0.html?gi-language=c

ffmpegcolorspace was removed and replaced with videoconvert

关于python-2.7 - GStreamer Python 错误 : 'gst.ElementNotFoundError: videoconvert' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60249261/

相关文章:

linux - gstreamer:输出窗口已关闭

java - java中Gstreamer的AppSrc绑定(bind)api

python :数字序列

python - 如何根据焦点设置Kivy TextInput背景颜色

python - 加载序列化 json 对象时出现问题

search - ubuntu:查找在特定日期更改的所有文件

c - 为什么用 void 关键字调用函数没有效果?

linux - 使用 -L 如何影响链接器?

python - 如何在 Mac OSX 上以简单的方式安装 gst-python (gstreamer python bind)?

python - 如何强制 python apns-client 避免使用 SSL 3?