Can't jpeg decoding using gstreamer

Hello,

I hope to decode jpeg from gstreamer rtsp streaming.

nvidia@nvidia-desktop:~/coding$ python3 rtsp_gst.py
Opening in BLOCKING MODE
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module udpsrc4 reported: Internal data stream error.
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ERROR:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap.cpp (116) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): rtspsrc location=rtsp://root:root@10.10.237.101:554/cam0_0 ! nvv4l2decoder mjpeg=1 ! nvvidconv ! video/x-raw, format=RGBA ! videoconvert ! video/x-raw,format=BGR ! appsink in function ‘icvExtractPattern’

rtsp open failed

source code is below.

import sys
import cv2

def read_cam():
# cap = cv2.VideoCapture("rtspsrc location=rtsp://root:root@10.10.237.101:554/cam0_0 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink ")
cap = cv2.VideoCapture("rtspsrc location=rtsp://root:root@10.10.237.101:554/cam0_2 ! nvv4l2decoder mjpeg=1 ! nvvidconv ! video/x-raw, format=RGBA ! videoconvert ! video/x-raw,format=BGR ! appsink ")
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()

Thank you.

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

$ gst-launch-1.0 rtspsrc location=rtsp://root:root@10.10.237.101:554/cam0_0 ! rtpjpegdepay ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! video/x-raw, format=RGBA ! videoconvert ! video/x-raw,format=BGR ! fakesink

If it works, you can try this gstreamer command in cv2.VideoCapture():

rtspsrc location=rtsp://root:root@10.10.237.101:554/cam0_0 ! rtpjpegdepay ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvvidconv ! video/x-raw, format=RGBA ! videoconvert ! video/x-raw,format=BGR ! appsink

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