Hi All,
I have a Jetson Tx2 running the latest Jetpack 4.2 SDK. I have plugged in 2 identical USB UVC Cameras that have a resolution of 160x120 at 9 Hz through a USB Hub to the Jetson’s USB 3.0 port through a USB 2.0 hub. All software is up to date.
I can capture with GStreamer from the commandline with gst-launch with either camera independently, one at a time - but not at the same time. I want to capture with both cameras at the same time, but the second capture command always fails with “Failed to allocate required memory”.
I’ve read elsewhere that 2 USB cameras are tough to get working due to USB bandwidth limitations and how the drivers allocate memory for worst case frame sizes, however my framerates and sizes are tiny compared to most modern cameras.
I think my math is correct, the USB 2.0 hub should be able to handle 2 cameras:
160 * 120 * 2 ( 16-bit ) * 9 = 345600 Bps * 8 = 2764800 ( 2.764800 Mbps )
2764800 * 2 cameras = 5529600 bps ( 5.529600 Mbps )
( 10 Mbps ) conservative USB 2.0 speed > 5.5 Mbps
How can I make this work?
Here is the failure for the second camera after the first is already streaming with the same parameters:
GST_DEBUG=2 gst-launch-1.0 -v v4l2src device=/dev/video2 ! videorate ! video/x-raw, width=160, height=120,format=GRAY16_LE,framerate=5/1 ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, width=(int)160, height=(int)120, format=(string)GRAY16_LE, framerate=(fraction)9/1, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:7:1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:src: caps = video/x-raw, width=(int)160, height=(int)120, format=(string)GRAY16_LE, framerate=(fraction)5/1, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:7:1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, width=(int)160, height=(int)120, format=(string)GRAY16_LE, framerate=(fraction)5/1, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:7:1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstFakeSink:fakesink0.GstPad:sink: caps = video/x-raw, width=(int)160, height=(int)120, format=(string)GRAY16_LE, framerate=(fraction)5/1, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:7:1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, width=(int)160, height=(int)120, format=(string)GRAY16_LE, framerate=(fraction)5/1, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:7:1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:sink: caps = video/x-raw, width=(int)160, height=(int)120, format=(string)GRAY16_LE, framerate=(fraction)9/1, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:7:1, interlace-mode=(string)progressive
0:00:00.235760607 9015 0x559713f4a0 WARN v4l2bufferpool gstv4l2bufferpool.c:790:gst_v4l2_buffer_pool_start:<v4l2src0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:00.243462223 9015 0x559713f4a0 ERROR v4l2bufferpool gstv4l2bufferpool.c:677:gst_v4l2_buffer_pool_streamon:<v4l2src0:pool:src> error with STREAMON 28 (No space left on device)
0:00:00.243520174 9015 0x559713f4a0 ERROR bufferpool gstbufferpool.c:564:gst_buffer_pool_set_active:<v4l2src0:pool:src> start failed
0:00:00.243951818 9015 0x559713f4a0 WARN v4l2src gstv4l2src.c:650:gst_v4l2src_decide_allocation:<v4l2src0> error: Failed to allocate required memory.
0:00:00.243993033 9015 0x559713f4a0 WARN v4l2src gstv4l2src.c:650:gst_v4l2src_decide_allocation:<v4l2src0> error: Buffer pool activation failed
0:00:00.244182247 9015 0x559713f4a0 WARN basesrc gstbasesrc.c:3275:gst_base_src_prepare_allocation:<v4l2src0> Subclass failed to decide allocation
0:00:00.244241415 9015 0x559713f4a0 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
Additional debug info:
gstv4l2src.c(650): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Buffer pool activation failed
0:00:00.244280390 9015 0x559713f4a0 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.021354625
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Here are the capabilities of both cameras:
nvidia@nvidia:~/Desktop$ v4l2-ctl --list-formats-ext -d /dev/video1
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'UYVY'
Name : UYVY 4:2:2
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Index : 1
Type : Video Capture
Pixel Format: 'Y16 '
Name : 16-bit Greyscale
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Size: Discrete 160x122
Interval: Discrete 0.111s (9.000 fps)
Index : 2
Type : Video Capture
Pixel Format: 'GREY'
Name : 8-bit Greyscale
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Index : 3
Type : Video Capture
Pixel Format: 'RGBP'
Name : 16-bit RGB 5-6-5
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Index : 4
Type : Video Capture
Pixel Format: 'BGR3'
Name : 24-bit BGR 8-8-8
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
nvidia@nvidia:~/Desktop$ v4l2-ctl --list-formats-ext -d /dev/video2
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'UYVY'
Name : UYVY 4:2:2
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Index : 1
Type : Video Capture
Pixel Format: 'Y16 '
Name : 16-bit Greyscale
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Size: Discrete 160x122
Interval: Discrete 0.111s (9.000 fps)
Index : 2
Type : Video Capture
Pixel Format: 'GREY'
Name : 8-bit Greyscale
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Index : 3
Type : Video Capture
Pixel Format: 'RGBP'
Name : 16-bit RGB 5-6-5
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
Index : 4
Type : Video Capture
Pixel Format: 'BGR3'
Name : 24-bit BGR 8-8-8
Size: Discrete 160x120
Interval: Discrete 0.111s (9.000 fps)
And here are the 2 commands I’d like to run at the same time:
gst-launch-1.0 -v v4l2src device=/dev/video1 ! video/x-raw, width=160, height=120,format=GRAY16_LE ! fakesink
gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x-raw, width=160, height=120,format=GRAY16_LE ! fakesink