Videocapture problem with rtsp cameras using gstreamer as apiPreference

Hey
I wanted to use Opencv+Gstreamer with msvc (compiled in vs2017) in c++ and with QT ( enabling: with_qt support in the cmake step). All the compilation and installing processes were fine without any problem, but when i try to do a simple qt project just openning a rtsp camera with the pipeline and gstreamer support in the videocapture does not work. I already tried with a lot of different pipelines, different versions of Opencv (4.0, 4.1, 4.5) but still nothing , there’s not errors at all, the videocapture just do not open the pipeline, in fact there are not much information about videocapture-rtsp-gstreamer-c++ , i’m starting to think that’s not possible, there are just some examples with the videowriter-gstreamer and python
I already tried with all these combinations of pipelines which are the most commons from what i investigated:
String ipRtsp=“rtsp://127.0.0.1:8554/test “;
// String pipelineCam=“rtspsrc location=”+ipRtsp+”! decodebin ! videoconvert ! appsink max-buffers=1 drop=true”;
// String pipelineCam=ipRtsp;
// String pipelineCam=“rtspsrc location=”+ipRtsp+“latency=10 ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! appsink”;
// String pipelineCam=“rtspsrc location=”+ipRtsp+“latency=10 ! rtph264depay ! h264parse ! decodebin ! autovideoconvert ! autovideosink”;
// String pipelineCam=“rtspsrc location=”+ipRtsp+“latency=60 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink”;
// String pipelineCam=“rtspsrc location=”+ipRtsp+“! decodebin ! videoconvert ! appsink”;//should work this one
// String pipelineCam=“uridecodebin uri=”+ipRtsp+“latency=20 ! videoconvert ! appsink”;
String pipelineCam=“rtspsrc location=”+ipRtsp+“! decodebin ! videoconvert ! appsink”;
// String pipelineCam=“rtspsrc location=”+ipRtsp+
// "! rtph264depay ! h264parse ! decodebin ! autovideoconvert ! autovideosink ";
mVideo.open(pipelineCam, cv::CAP_GSTREAMER);
Opencv stopped supporting videocapture-gstreamer-rtsp in recent versions?
Any idea?
thanks in advance

  • show resp. code snippet, please
  • check cout << cv::getBuildInformation() << endl; (esp. the “Video IO” part) for what you have builtin
  • set OPENCV_VIDEOIO_DEBUG=1 on the console, then run your program from there, should give logging output about what backends were tried
  • the ffmpeg backend should be able to retrieve rtsp streams, too.

Hi @berak thanks for your reply,
*yes it works with ffmpg, i usually work with this but i wanted to start working with gstreamer because of the performance, flexibility, for example with ffmpg i can’t use ffmpg over tcp, i can’t get the last frame i have to free all the buffer, etc.
*When i set that getBuildInformation() i get that gstreamer is enabled, same results as with the opencv build process
Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (58.91.100)
avformat: YES (58.45.100)
avutil: YES (56.51.100)
swscale: YES (5.7.100)
avresample: YES (4.0.0)
GStreamer: YES (1.16.2)
DirectShow: YES
Media Foundation: YES
DXVA: YES
*With that videioio flag set i’m getting these new warnings:

  1. [ WARN:0] global C:\OpenCV4.5\opencv-4.5.0\modules\videoio\src\cap.cpp (108) cv::VideoCapture::open VIDEOIO(GSTREAMER): trying capture filename=‘rtspsrc location=rtsp://127.0.0.1:8554/test ! decodebin ! videoconvert ! appsink’ …

  2. [ WARN:0] global C:\OpenCV4.5\opencv-4.5.0\modules\videoio\src\cap_gstreamer.cpp (888) cv::GStreamerCapture::open OpenCV | GStreamer warning: unable to start pipeline

  3. [ WARN:0] global C:\OpenCV4.5\opencv-4.5.0\modules\videoio\src\cap_gstreamer.cpp (480) cv::GStreamerCapture::isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

  4. [ WARN:0] global C:\OpenCV4.5\opencv-4.5.0\modules\videoio\src\cap.cpp (131) cv::VideoCapture::open VIDEOIO(GSTREAMER): can’t create capture

btw there’s a warning what is showing with one of my opencv versions:
[ WARN:0] global C:\OpenCV4.5\opencv-4.5.0\modules\videoio\src\cap_gstreamer.cpp (1745) cv::handleMessage OpenCV | GStreamer warning: your GStreamer installation is missing a required plugin[ WARN:0] global C:\OpenCV4.5\opencv-4.5.0\modules\videoio\src\cap_gstreamer.cpp (1761) cv::handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module decodebin0 reported: Your GStreamer installation is missing a plug-in.