GStreamer 动态改变图像大小

GStreamer change image size dynamically

首先:是的,我知道之前有人问过这个问题,但答案并没有真正帮助我,因为我还不太熟悉 Gstreamer,我需要更多帮助。我正在尝试使用 videocrop 创建管道并动态更改值。以下是我的代码,其中 returns 错误: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()

我真的成功了!我试错了。以下作品:

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()