Problem with second USB camera on Xavier NX

I have two USB 3.0 1080p ELP cameras that I am trying to use on my Xavier NX board. I’ve previously tried them with a Nano, and got an error that indicated that the board was running out of bandwidth (likely a problem with uvc video driver). This time, I am not getting this error, but a problem nevertheless occurs.
If I use gstreamer to open a stream, via gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink, the first camera starts fine. The second stream however always shows a frozen screen with the contents of the desktop when I initiate it. If I close one of the gstreamer windows, the second one unfreezes and works normally. No error occurs, just the freeze, so I’m not sure what is causing this behavior.
If I use python and opencv, a single camera again works fine. However, when allocating for a second video capture, python gives the following error:

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

No video opens. This occurs at the second of the following two lines:

cap1 = cv2.VideoCapture(0)
cap2 = cv2.VideoCapture(1)

I have no idea whether this is related to the Nano’s problem of bandwidth being exceeded, or if it’s completely different. Would greatly appreciate any input.

Edit: I’ve accidentally created this post in the wrong branch. If possible, could an admin move this to the Xavier NX forum? Thank you.

Hi,
Please check if you can launch the camera by following the steps in Jetson Nano FAQ
Q: I have a USB camera. How can I lauch it on Jetson Nano?
The steps are valid for all Jetson platforms. You may try and see if you can launch the two cameras through gst-launch-1.0 commands.

And you can execute sudo jetson_clocks to get max performance.

Thank you for your reply. I did launch the two cameras through gst-launch-1.0 commands: the first part of my post is about that. Specifically, I used:

gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink
gst-launch-1.0 v4l2src device=/dev/video1 ! xvimagesink

The first camera always opens fine, but the second one is frozen and freezes the first. Closing any of the open cameras unfreezes the remaining one. No error is generated.

Hi,
We connect two E-Con CU135 USB cam to Xavier NX and both can be launched in 1080p30. The command for launching the cameras is

$ gst-launch-1.0 v4l2src device=/dev/video2 ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvegltransform ! nveglglessink

Would suggest you check the steps in FAQ and set exact mode including width,height,format,framerate. And by default two CPUs are enabled. You can run sudo nvpmodel -m 2 to enable six CPUs for a try.

Hi, thanks for your reply. I tried the following according to what my camera should support:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=50/1 ! nvvidconv ! ‘video/x-raw(memory:NVMM),format=NV12’ ! nvegltransform ! nveglglessink

However, it never launches a video window but quits saying:

streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn’t want to preroll.

The same error is observed for a different (non-USB 3.0) camera. The only way I’ve found to launch a video is by using the:

gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink

command. I can also confirm that one of my ELP USB 3.0 cameras does indeed open with this command alongside a second non-USB 3.0 camera, with both active at the same time. It is only a second ELP camera that freezes the screen. I have the Xavier NX in 6-core mode.

Could you point me to the specific FAQ you are referring to? I cannot seem to build a working pipeline aside from the default one with xvimagesink.

Hi,
Please check Jetson Nano FAQ
Q: I have a USB camera. How can I lauch it on Jetson Nano?

I can confirm that none of my cameras launch using the commands in that FAQ. The error given is always like this:

ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)

Can I assume something is wrong with my cameras (keep in mind there are several kinds I’ve tested)? I made sure all the parameters are as supported by the cameras.

Hi,
Please share information of the source for reference:

$ v4l2-ctl -d /dev/video0 --list-formats-ext

The output is:

ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘MJPG’ (compressed)
Name : Motion-JPEG
Size: Discrete 1920x1080
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.017s (60.000 fps)

Index : 1
Type : Video Capture
Pixel Format: ‘YUYV’
Name : YUYV 4:2:2
Size: Discrete 1920x1080
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.017s (60.000 fps)

Hi,
Looks like the framerate does not match. Please try

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=60/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvoverlaysink

Hi, I noticed that too: the specifications on the camera say 50fps, but the v4l2-ctl utility gives 60. I tried both ways (including your exact command), both give the same error I mentioned above.
Edit: no, it works properly, I made a typo. However, opening a second camera still freezes the feed. No errors appear, just frozen cameras.

Hi

I have a usb camera Joytron. How can I add this with jetson xavier nx. I can not do this as it says no connection.

Maruf

Hi maruf.ahmad,

Please help to open a new topic for your issue with more details. Thanks.