OpenCV with Gstreamer blocked on read when server rtsp disconnect
www.andreabertolaso at gmail.com
Tue Sep 25 15:22:25 UTC 2018
I'm tring to build an application with Gstreamer (v.1.14.2) and VideoCapture
from OpenCV (v.3.4.3). My goal is to obtain a 4k stream from an IP camera
via rtsp protocol.
This is the code:
int main(int argc, char *argv)
static std::string pipe = "rtspsrc
protocols=GST_RTSP_LOWER_TRANS_TCP timeout=5000000 ! rtph264depay ! queue !
avdec_h264 ! videoconvert ! appsink";
cv::VideoCapture *p_video_capture = nullptr;
if (!p_video_capture || !p_video_capture->isOpened())
p_video_capture = new cv::VideoCapture(pipe, CV_CAP_GSTREAMER);
std::cout << "VideoCapture open" << std::endl;
bool res = p_video_capture->read(img);
p_video_capture = nullptr;
Everthing is fine util I disconnect the camera by unplugging the cable. Two
scenarios might happen:
1) VideoCapture detects the disconnection and the read() function return
false (desired behaviour);
2) VideoCapture gets stucked in the read() function (undesired behaviour).
This seems to be a non-deterministic behaviour. In the second case I was
able to print some warning messages by setting the environment variable
GST_DEBUG to 5. The system keeps printing the same set of messages in the
For every itaration an incremental number is assignet to each element of the
pipilene (e.g. rtspsrc66 in the attached file).
After 1 hour and 39 minutes I got the 294 useless iteration.
I cannot say if this is a problem of opencv or gstremer. Have you any
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel