HW decode rtsp distribution video with gstreamer with opencv

Hi

I have a problem using gstreamer to HW decode the video delivered by rtsp using opencv with Jetpack 4.6.

System setup was done with Docker using https://github.com/dusty-nv/jetson-inference

import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("rtspsrc location=rtsp://172.1.1.1:8554/camera latency=2000 ! queue ! rtph264depay ! h264parse ! omxh264dec ! video/x-raw ! nveglglessink ", cv2.CAP_GSTREAMER)
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read();
            cv2.imshow('demo',img)
            cv2.waitKey(10)
    else:
     print ("rtsp open failed")

    cv2.destroyAllWindows()
 if __name__ == '__main__':
    read_cam()

When executed, it will be as follows

[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (803) open OpenCV | GStreamer warning: cannot find appsink in manual pipeline
[ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
rtsp open failed

The video output of RTSP distribution video has been confirmed by vlc player.
why?

Thank you

Hi,
The pipeline should end with appsink. Please try

cap = cv2.VideoCapture("rtspsrc location=rtsp://172.1.1.1:8554/camera latency=2000 ! queue ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink ", cv2.CAP_GSTREAMER)

It worked with the changes as you suggested.
Thank you

1 Like

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