I am having trouble using the gstreamer rstp with opencv on Jetson.
I can use gst launcher command to open and display the rstp source.
I searched online that some people has successfully using this code to read rtsp in opencv.
[ WARN:0] global /home/correct-ai/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (1761) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module udpsrc3 reported: Internal data stream error.
[ WARN:0] global /home/correct-ai/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/correct-ai/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
And cap.isOpened() gives me False.
Did I make a mistake somewhere?
Thanks for the reply,
After replace omxh264dec with nvv4l2decoder , it still cannot open the cap. (cap.isOpened returns False), and the output is the same.
I also tried your example with public link, it works well (with some warnings showing on the terminal).
But when I replaced the rtsp location to my camera, it does not work anymore.
I use gst-launch-1.0 command and it works fine with the camera, which suggests no connection issue.
but it fails if you apply it to cv2.VideoCapture() with appsink. A bit strange for this situation. Generally if it works in gst-launch-1.0 command, it should also work in cv2.VideoCapture().
When I try the command you provided, it cannot open the video feed:
The output:
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.10:554/user=admin_password=xxxxxx_channel=1_stream=0.sdp
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
WARNING: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstRtpH264Depay named rtph264depay0
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3:
streaming stopped, reason not-linked (-1)
Execution ended after 0:00:02.109489167
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...