Problem with Gstream and Opencv on Jetson nano

Hello, i am absolute new in this theme. I installed opencv and vscode on my jetson nano. Now i want to test if i am able to show my ip camera stream via the opencv code. The dummy/example worked grate but now i tried to use my camera stream and no window appeared, only this few lines of code showed up in the command line :
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 279
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 279

Here my code:

#include <iostream>
#include <opencv2/opencv.hpp>
#include <iostream>

int main() {
  
    std::string pipeline =
        "rtspsrc location=rtsp://admin:projektarbeit2025\\[email protected]:554/h264Preview_01_main latency=0 ! "
        "decodebin ! videoconvert ! appsink";

    // VideoCapture mit GStreamer öffnen
    cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER);
    if (!cap.isOpened()) {
        std::cerr << "Fehler: Kann den RTSP-Stream nicht öffnen." << std::endl;
        return -1;
    }

    cv::Mat frame;
    while (true) {
        if (!cap.read(frame)) {
            std::cerr << "Stream beendet oder Frame nicht lesbar." << std::endl;
            break;
        }

        cv::imshow("RTSP-Stream", frame);
        if (cv::waitKey(1) == 'q') break;
    }

    cap.release();
    cv::destroyAllWindows();
    return 0;
}

thanks for your Help :)

Hi,
Please apply the URL to this sample and see if it works:
Doesn't work nvv4l2decoder for decoding RTSP in gstreamer + opencv - #3 by DaneLLL
And you can run the pipeline with fakesink in gst-launch-1.0 command like:

$ gst-launch-1.0 rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! 'video/x-raw, format=(string)BGRx' ! videoconvert ! video/x-raw,format=BGR ! fakesink

To ensure the pipeline is good.

Hi with this code i got this error: bash: syntax error near unexpected token `(’

But Chatgpt helped me to create this. If i run this it works very well:

gst-launch-1.0 -v rtspsrc location=rtsp://admin:projektarbeit2025!@192.168.178.178:554/h264Preview_01_main latency=0 ! decodebin ! autovideosink

Hi,
Please run with your RTSP URL.

Hi, thanks for your help, but the “format=(string)BGRx” isnt working, the “(“ seems to be a problem. The code i posted above is working. I dont know why this is throwing an exception. I will try another time on monday :)

Hi,
Please try format=BGRx. It should work without (string).

Hi,
Please try the command and see if it works:

$ gst-launch-1.0 rtspsrc location="rtsp://admin:[email protected]:554/h264Preview_01_main" ! rtph264depay ! h264parse ! nvv4l2decoder ! fakesink

std::string pipeline =
"rtspsrc location=rtsp://admin:projektarbeit2025\!@192.168.178.178:554/h264Preview_01_main latency=100 protocols=tcp ! "
"application/x-rtp,media=video,encoding-name=H265 ! "
"rtph265depay ! h265parse ! nvv4l2decoder ! "
"nvvidconv ! video/x-raw,format=BGRx ! "
"videoconvert ! video/x-raw,format=BGR ! "
“appsink max-buffers=1 drop=true”;

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.