问题
I'm using OpenCV and GStreamer 0.10.
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"
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 :]
回答1:
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"
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
It worked well now, just need to delete "blocksize=1316 closefd=false buffer-size=5600" to release the limitation.
来源:https://stackoverflow.com/questions/38546602/grab-the-frame-from-gst-pipeline-to-opencv-with-python