首页 > 解决方案 > GStreamer 动态更改图像大小

问题描述

首先:是的,我知道之前有人问过这个问题,但答案并没有真正帮助我,因为我对 Gstreamer 还不是很熟悉,我需要更多帮助。我正在尝试创建一个管道videocrop并动态更改值。以下是我返回错误的代码:TypeError: object of type GstVideoCrop does not have property caps. 所以我想这是不可能的,或者我做错了......谢谢你的帮助!

import gi
gi.require_version('Tcam', '0.1')
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, Tcam

GObject.threads_init()
Gst.init(())
p = Gst.parse_launch("tcambin name=src ! video/x-raw, format=BGRx ! videocrop name=try top=0 left=300 right=150 bottom=0 ! videoconvert ! ximagesink")
p.set_state(Gst.State.PLAYING)
p.set_state(Gst.State.READY)
m = p.get_by_name("try")
caps = Gst.caps_from_string("videocrop name=try top=500 left=300 right=150 bottom=0")
m.set_property("caps", caps)
p.set_state(Gst.State.PLAYING)
GObject.MainLoop.run()

标签: pythongstreamer

解决方案


我真的让它工作了!我以错误的方式尝试它。以下作品:

import gi
gi.require_version('Tcam', '0.1')
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, Tcam

GObject.threads_init()
Gst.init(())
p = Gst.parse_launch("tcambin name=src ! video/x-raw, format=BGRx ! videocrop name=caps top=0 left=300 right=150 bottom=0 ! videoconvert ! ximagesink")
p.set_state(Gst.State.PLAYING)
p.set_state(Gst.State.READY)
m = p.get_by_name("caps")

m.set_property("top", 500)
p.set_state(Gst.State.PLAYING)
GObject.MainLoop.run()

推荐阅读