繁体   English   中英

显示没有gtk的图像

[英]Display image without gtk

我想使用gstreamer绑定在Python中显示图像,但不使用GTK +(我在ARM上)。

我知道如何用python和gstreamer听音乐:

#!/usr/bin/python
# Simply initiates a gstreamer pipeline without gtk
import gst
import gobject
import sys

mainloop = gobject.MainLoop()
my_bin = gst.element_factory_make("playbin")
my_bin.set_property("uri", "file:///home/Lumme-Badloop.ogg")
my_bin.set_state(gst.STATE_PLAYING)

try:
    mainloop.run()
except KeyboardInterrupt:
    sys.exit(0)    

我知道如何在命令行中使用gstreamer显示图像:

gst-launch-0.10 filesrc location=image.jpeg ! jpegdec ! freeze ! videoscale ! ffmpegcolorspace ! autovideosink

我想要的是完全相同的东西,但使用Python。

我尝试了一些东西,代码运行没有错误,但屏幕上没有任何显示。

pipe = gst.Pipeline("mypipe")

source = gst.element_factory_make("filesrc", "filesource")
demuxer = gst.element_factory_make("jpegdec", "demuxer")
freeze = gst.element_factory_make("freeze", "freeze")
video = gst.element_factory_make("videoscale", "scaling")
ffm = gst.element_factory_make("ffmpegcolorspace", "muxer")
sink = gst.element_factory_make("autovideosink", "output")

pipe.add(source, demuxer, freeze, video, ffm, sink)

filepath = "file:///home/image.jpeg"
pipe.get_by_name("filesource").set_property("location", filepath)

pipe.set_state(gst.STATE_PLAYING)

你有什么想法可以帮助我吗?

谢谢提前!

顺便说一句,我也有audiotest和videotest工作。 这是一个运行正常的示例:

# Create GStreamer pipeline
pipeline = gst.Pipeline("mypipeline")
# Set up our video test source
videotestsrc = gst.element_factory_make("videotestsrc", "video")
# Add it to the pipeline
pipeline.add(videotestsrc)
# Now we need somewhere to send the video
sink = gst.element_factory_make("xvimagesink", "sink")
# Add it to the pipeline
pipeline.add(sink)
# Link the video source to the sink-xv
videotestsrc.link(sink)

pipeline.set_state(gst.STATE_PLAYING)

试试:

filepath =“/ home / image.jpeg”

filesrc的location属性采用文件路径,而不是URI。 您应该检查管道总线上的错误消息。 或者使用GST_DEBUG = *:3 yourapp.py运行代码以查看是否存在问题/错误。

此外,你可以做到

pipeline = gst.parse_launch(“filesrc location = / home / foo / image.jpg!jpegdec!....”)

而不是自己构建管道(对于简单的事情,无论如何,parse_launch有点限制)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM