使用python从gst管道抓取框架到opencv [英] Grab the frame from gst pipeline to opencv with python
问题描述
我正在使用 OpenCV 和GStreamer 0.10 .
I'm using OpenCV and GStreamer 0.10.
我使用此管道使用python提供的自定义套接字sockfd
通过UDP接收MPEG ts数据包,并用xvimagesink
显示它,并且效果很好.以下是此管道的推荐行:
I use this pipeline to receive the MPEG ts packets over UDP with a custom socket sockfd
provided by python and display it with xvimagesink
, and it works perfectly. Following commend line is for this pipeline:
PIPELINE_DEF = "udpsrc do-timestamp=true name=src blocksize=1316 closefd=false buffer-size=5600 !" \
"mpegtsdemux !" \
"queue !" \
"ffdec_h264 max-threads=0 !" \
"ffmpegcolorspace !" \
"xvimagesink name=video"
现在,我想从此管道中获取一帧并使用OpenCV进行显示.我该怎么做?我对从appsink获取缓冲区数据了解很多.但是我仍然不知道如何将这些缓冲区转换为OpenCV的每个帧.感谢您的回复,以及任何帮助:]
Now, I want to get one frame from this pipeline and display it with OpenCV. How can I do it? I know a lot about getting buffer data from appsink. But I still do not know how to convert those buffer to each frames for OpenCV. Thanks for reply, and any help :]
推荐答案
谢谢,我尝试使用rtph264pay将实时视频流广播到udpsink.以下推荐行适用于gst管道:
Thanks, I have tried to use rtph264pay to broadcast the live video steam to udpsink. Following commend line is for the gst pipeline:
PIPELINE_DEF =
"udpsrc name=src !" \
"mpegtsdemux !" \
"queue !" \
"h264parse !" \
"rtph264pay !" \
"udpsink host=127.0.0.1 port=5000"
我建立了一个sdp文件,以使opencv喜欢videocapture("123.sdp")123.sdp可以接收它,以下内容是此sdp文件的内容:
And I built a sdp file to make it can be received by opencv likes videocapture("123.sdp") 123.sdp, following content is for this sdp file:
c=IN IP4 127.0.0.1
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000
现在效果很好,只需删除"blocksize = 1316 closefd = false buffer-size = 5600"即可解除限制.
It worked well now, just need to delete "blocksize=1316 closefd=false buffer-size=5600" to release the limitation.
这篇关于使用python从gst管道抓取框架到opencv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!