Tôi muốn hiển thị hình ảnh bằng Python bằng cách sử dụng các liên kết gstreamer, nhưng không sử dụng GTK + (Tôi đang ở trên ARM).Hình ảnh hiển thị không có gtk
tôi biết làm thế nào để nghe nhạc với trăn và 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)
tôi biết làm thế nào để hiển thị một hình ảnh với GStreamer trong dòng lệnh:
gst-launch-0.10 filesrc location=image.jpeg ! jpegdec ! freeze ! videoscale ! ffmpegcolorspace ! autovideosink
Những gì tôi muốn là chính xác điều tương tự, nhưng sử dụng Python.
Tôi đã thử một số thứ, mã chạy mà không có lỗi, nhưng không có gì hiển thị trên màn hình.
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)
Bạn có ý tưởng nào có thể giúp tôi không?
Cảm ơn trước!
Nhân tiện, tôi cũng có công việc âm thanh và băng video. Dưới đây là một ví dụ mà chạy tốt:
# 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)
Bạn đã thử các bồn rửa khác như 'xvimagesink' hoặc' ximagesink'? – jcollado
Tôi đã, tại thời điểm này. Tôi có một ví dụ làm việc với videoink. Tôi đặt nó ở cuối bài viết của tôi. cảm ơn sự giúp đỡ – jlengrand
@jlengrand: Bạn có thể trả lời câu hỏi của riêng mình và đóng câu hỏi này. Nó bình thường như thế nào chúng ta xử lý các tình huống như thế này. – Will