VideoCapture::open() blocks when using CAP_GSTREAMER

Hi,

I am currently facing an issue with VideoCapture::open() method when using CAP_GSTREAMER as a receiver.
The VideoCapture::open() method blocks until something is received thus blocking my whole application.
I did not find any way to make the open() method fail or return.

I am using OpenCV 4.1, and I tried with OpenCV 4.6 and I am still facing the same issue.
However with OpenCV 4.6 I get an error message I did not have before:

global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (1405) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=0, duration=-1

This is the pipeline I am using;
auto command = fmt::format(“udpsrc port={} timeout={} caps=application/x-rtp ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! appsink sync=false”, port, timeout);

And this is my call to open:
m_capture->open(command, cv::VideoCaptureAPIs::CAP_GSTREAMER);

Does anyone has an idea of why I am facing this issue ?

Thanks in advance,

Wilfred

Have you found any solution to this problem? IS there a GStreamer pipeline element that could help?

I have used this code that sometimes works depending on the state a camera is in:

        std::future<bool> future_open = std::async(std::launch::async, [access, resource_path_name, config]
        {
             return access->open(resource_path_name, VIDEO_PROVIDER_API);
        });
        
        //Wait for 5 seconds
        std::this_thread::sleep_for(std::chrono::seconds(5));

        //Check if the future is ready, wait for a ready signal, great, but if not then timeout has occurred or some other error
        if (future_open.wait_for(std::chrono::seconds(0)) == std::future_status::timeout) {

            //The future is not ready, terminate the thread
            future_open.get();
        }

Sometimes the .get() call blocks, so I assume the GStreamer pipeline is blocking…

Hello,

Thank you for your response. Yes I did find the solution, and it was due to a missing x264 dependency.
We figure that out after seeing this message when running the pipeline manually (outside of C++)
“WARNING: erroneous pipeline: no element “x264enc””.