
为了详细说明ensonic的答案,下面是一个示例:
import osimport sysimport gstdef get_frame(path, offset=5, caps=gst.Caps('image/png')): pipeline = gst.parse_launch('playbin2') pipeline.props.uri = 'file://' + os.path.abspath(path) pipeline.props.audio_sink = gst.element_factory_make('fakesink') pipeline.props.video_sink = gst.element_factory_make('fakesink') pipeline.set_state(gst.STATE_PAUSED) # Wait for state change to finish. pipeline.get_state() assert pipeline.seek_simple( gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, offset * gst.SECOND) # Wait for seek to finish. pipeline.get_state() buffer = pipeline.emit('convert-frame', caps) pipeline.set_state(gst.STATE_NULL) return bufferdef main(): buf = get_frame(sys.argv[1]) with file('frame.png', 'w') as fh: fh.write(str(buf))if __name__ == '__main__': main()这将生成一个PNG图像。您可以使用
gst.Caps("video/x-raw-rgb,bpp=24,depth=24")或类似方式获取原始图像数据。请注意,在GStreamer 1.0(而不是0.10)中,
playbin2已重命名为
playbin,
convert-frame信号被命名为
convert-sample。
在GStreamer应用程序开发手册的这一章中介绍了寻找的方法。0.10
playbin2文档似乎不再在线,但是1.0的文档在这里。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)