RTSP Jetson nano

I have problems with the execution of the ip camera through the rtps protocol

import jetson.inference
import jetson.utils

net = jetson.inference.detectNet(“ssd-mobilenet-v2”, threshold=0.5)
camera = jetson.utils.videoSource(“rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1”)
display = jetson.utils.videoOutput(“display://0”) # ‘my_video.mp4’ for file

while display.IsStreaming():
img = camera.Capture()
detections = net.Detect(img)
display.Render(img)
display.SetStatus(“Object Detection | Network {:.0f} FPS”.format(net.GetNetworkFPS()))

the problem is> Exception: jetson.utils – failed to create videoSource device

Can you provide the complete terminal log please?

Also you can try disabling the user login on your camera, and seeing if it is an authentication issue.

Alternatively, if you already have the RTSP capture working with your camera through OpenCV, you can see this example for converting the OpenCV buffer to CUDA:

https://github.com/dusty-nv/jetson-utils/blob/833fc7998e34d852672277730a11aeed90024959/python/examples/cuda-from-cv.py

Additional note: a user reported authentication problems with RTSP related to having gstreamer1.0-plugins-ugly installed.

i can open with OPEN CV without problem. I have a IP CAMERA DAHUA

./my-detection.py
[gstreamer] initialized gstreamer, version 1.14.5.0
[gstreamer] gstDecoder – creating decoder for admin:admin1234@192.168.1.108
[gstreamer] gstDecoder – Could not open resource for reading and writing.
[gstreamer] gstDecoder – try manually setting the codec with the --input-codec option
[gstreamer] gstDecoder – failed to create decoder for rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1
Traceback (most recent call last):
File “./my-detection.py”, line 29, in
camera = jetson.utils.videoSource(“rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1”) #csi://0
Exception: jetson.utils – failed to create videoSource device

That user was also able to connect from opencv using ffmpeg backend.
But using gstreamer was failing.
Does the following work ?

gst-launch-1.0 uridecodebin uri="rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1" ! nvoverlaysink
1 Like

gst-launch-1.0 uridecodebin uri=“rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1” ! nvoverlaysink
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1
ERROR: from element /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Could not open resource for reading and writing.
Additional debug info:
gstrtspsrc.c(7469): gst_rtspsrc_retrieve_sdp (): /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source:
Failed to connect. (Generic error)
ERROR: pipeline doesn’t want to preroll.
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

So it seems it doesn’t work with gstreamer…
You may try to remove plugins-ugly :

 sudo apt-get remove gstreamer1.0-plugins-ugly

and retry.

yes this command works,

gst-launch-1.0 uridecodebin uri=“rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1” ! nvoverlaysink

less missing, at now?

Sorry to say that, but:

  • You’re asking for help but didn’t say please
  • You never say thank you once in this topic
  • Seems nobody clicked on the link I had provided. Reading that topic would have allowed you to move further and would have saved me two posts.

Politeness is not mandatory in the Code of Conduct of this forum, ok.
But for me, it’s enough for today.
Wish you good luck however.

My English is not good, I did not mean to offend you,
I apologize

It’s ok, I’m a good dog !

So as now you can open the stream with gstreamer, you would:

  • first be sure to get recent version of jetson-inference and jetson-utils, rebuild and reinstall these.
  • Then, try changing your code to:
camera = jetson.utils.videoSource("rtsp://admin:admin1234@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1", argv=['--input-codec=H264'])

[EDIT: You may also have to create the glDisplay before the rtsp source. In my case it fails to create the glDisplay after the rtsp video source, but succeeds if created before. @dusty_nv, any hint ?]

3 Likes

thank you very much you are the best, it works

1 Like