reading frames from mjpeg stream gstreamer, c++

asked 2016-08-23 08:52:07 -0600

marcin gravatar image

Hello,

I wrote a simple app which should read frames from mjpeg stream gstreamer. It works if I use gst-launch-1.0, but it does not work in opencv 3.1.0 in c++. Here are the details: This client-server combination works:

Server: gst-launch-1.0 -v v4l2src device=/dev/video0 ! "video/x-raw, width=640,height=480" ! jpegenc ! rtpjpegpay ! udpsink host=127.0.0.1 port=1111

Client: gst-launch-1.0 -v udpsrc port=1111 ! "application/x-rtp, payload=127" ! rtpjpegdepay ! jpegdec ! xvimagesink sync=false

However if I try to implement client in c++ using opencv:

cv::VideoCapture capture("udpsrc port=1111 ! application/x-rtp,payload=127 ! rtpjpegdepay ! jpegdec ! appsink");

It gives me the following error:

GStreamer Plugin: Embedded video playback halted; module udpsrc0 reported: Internal data flow error. OpenCV Error: Unspecified error (GStreamer: unable to start pipeline ) in cvCaptureFromCAM_GStreamer, file /home/marcin/dev/3rdparty/opencv-3.1.0/modules/videoio/src/cap_gstreamer.cpp, line 818 terminate called after throwing an instance of 'cv::Exception' what(): /home/marcin/dev/3rdparty/opencv-3.1.0/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline in function cvCaptureFromCAM_GStreamer

What is wrong in my code?

edit retag flag offensive close merge delete