[英]How to create gstreamer pipeline in python with a probe
I am trying to write a code that takes image input, writes some text over it, and then sends it to the sink (app, file, or Gtk display).我正在尝试编写一个代码,该代码接受图像输入,在其上写入一些文本,然后将其发送到接收器(应用程序、文件或 Gtk 显示器)。
The code below works in the terminal and through python:下面的代码在终端中通过 python 工作:
pipeline = Gst.parse_launch(f"videotestsrc ! videoscale ! video/x-raw,width=1920,height=1080 ! autovideosink")
I need a probe here to put some text on the images, so I have converted this in the gi
format for manipulating it.我需要一个探针来在图像上放置一些文本,因此我将其转换为
gi
格式以进行操作。 The code gives no visual or text output.该代码没有给出视觉或文本 output。 Is there anything wrong with the code:
代码有什么问题吗:
pipeline = Gst.Pipeline()
source = Gst.ElementFactory.make("videotestsrc", "video-source")
pipeline.add(source)
scale = Gst.ElementFactory.make("videoscale", "scale")
pipeline.add(scale)
caps = Gst.Caps.from_string("video/x-raw,width=1920,height=1080")
filter = Gst.ElementFactory.make("capsfilter", "filter")
filter.set_property("caps", caps)
pipeline.add(filter)
scale.link(filter)
sink = Gst.ElementFactory.make("autovideosink", "video-sink")
pipeline.add(sink)
filter.link(sink)
loop = GLib.MainLoop()
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except Exception as e:
print(e)
pipeline.set_state(Gst.State.NULL)
You didn't link your videotestsrc
to your videoscale
element.您没有将
videotestsrc
链接到您的videoscale
元素。 In other words, you forgot换句话说,你忘记了
source.link(scale)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.