我尝试从GStreamer框架实时接收帧到帧的numpy数组。在
我已经尝试在Python中使用类似这样的管道(来自http://stackoverflow.com/questions/8187257/play-audio-and-video-with-a-pipeline-in-gstreamer-python/8197837并进行修改):
self.filesrc = Gst.ElementFactory.make('filesrc')
self.filesrc.set_property('location', self.source_file)
self.pipeline.add(self.filesrc)
# Demuxer
self.decoder = Gst.ElementFactory.make('decodebin')
self.decoder.connect('pad-added', self.__on_decoded_pad)
self.pipeline.add(self.decoder)
# Video elements
self.videoqueue = Gst.ElementFactory.make('queue', 'videoqueue')
self.pipeline.add(self.videoqueue)
self.autovideoconvert = Gst.ElementFactory.make('autovideoconvert')
self.pipeline.add(self.autovideoconvert)
self.autovideosink = Gst.ElementFactory.make('autovideosink')
self.pipeline.add(self.autovideosink)
# Audio elements
self.audioqueue = Gst.ElementFactory.make('queue', 'audioqueue')
self.pipeline.add(self.audioqueue)
self.audioconvert = Gst.ElementFactory.make('audioconvert')
self.pipeline.add(self.audioconvert)
self.autoaudiosink = Gst.ElementFactory.make('autoaudiosink')
self.pipeline.add(self.autoaudiosink)
self.progressreport = Gst.ElementFactory.make('progressreport')
self.progressreport.set_property('update-freq', 1)
self.pipeline.add(self.progressreport)
所有管道也已链接。但是,我不知道如何从流中实时执行numpy数组检索。你有什么建议吗?在
原始问题中的管道设计用于显示视频和播放音频,因此它分别使用}元素。如果希望视频帧转到应用程序而不是屏幕,则需要使用另一个sink元素,即}。在
autovideosink
和{appsink
而不是{
^{pr2}$appsink
元素有一个名为“newsample”的信号,当有新的帧可用时,您可以连接到该信号。在然后是将GStreamer的缓冲区格式转换为Numpy数组的问题。在
注意,这段代码对帧数据做了某些假设,即它是一种类似RGB的3色格式,并且颜色数据将是无符号的8位整数。在
相关问题 更多 >
编程相关推荐