gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:50:10 25 4
gpt4 key购买 nike

我正在尝试创建一个简单的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com