VIM4 Dual Webcam Gstreamer Error

Which system do you use? Android, Ubuntu, OOWOW or others?

Ubuntu

Which version of system do you use? Please provide the version of the system here:

Ubuntu 24.04, Kernel 5.15.119

Please describe your issue below:

I have 2 identical USB webcams connected to the 2 USB ports of the VIM4. I can execute a gstreamer that shows each of them individually but cannot use both simultaneously. I have tried both a gstreamer compositor and also and OpenCV python script consuming both as gstreamer cameras.

Post a console log of your issue below:

GST_DEBUG=3  gst-launch-1.0 compositor name=comp \
sink_0::xpos=0 sink_0::ypos=0 sink_0::width=640 sink_0::height=480 \
sink_1::xpos=0 sink_1::ypos=480 sink_1::width=640 sink_1::height=480 \
! queue ! amlvenc ! rtph264pay ! udpsink port=5001 host=192.168.2.236 \
v4l2src device=/dev/video0 ! image/jpeg,width=640,height=480,framerate=60/1 ! jpegdec ! queue ! comp.sink_0 \
v4l2src device=/dev/video2 ! image/jpeg,width=640,height=480,framerate=60/1 ! jpegdec ! queue ! comp.sink_1

Setting pipeline to PAUSED ...
[API:aml_v4l2src_connect:271]Enter, devname : /dev/video0
driver : uvcvideo
device : Global Shutter Camera: Global S
bus_info : usb-xhci-hcd.0.auto-1.1
version : 331639
strcmp cap.driver: uvcvideo
[API:aml_v4l2src_connect:298]Exit, USB camera
devname : /dev/video0
driver : uvcvideo
device : Global Shutter Camera: Global S
bus_info : usb-xhci-hcd.0.auto-1.1
version : 331639
error tvin-port use -1 
[API:aml_v4l2src_connect:271]Enter, devname : /dev/video2
driver : uvcvideo
device : Global Shutter Camera: Global S
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
strcmp cap.driver: uvcvideo
[API:aml_v4l2src_connect:298]Exit, USB camera
devname : /dev/video2
driver : uvcvideo
device : Global Shutter Camera: Global S
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
error tvin-port use -1 
0:00:02.440399610  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src0> Can't give latency since framerate isn't fixated !
0:00:02.441030891  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src1> Can't give latency since framerate isn't fixated !
0:00:02.441160889  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:2283:gst_aggregator_query_latency_unlocked:<comp> Latency query failed
[API:aml_v4l2src_streamon:373]Enter
[API:aml_v4l2src_streamon:376]Exit
[API:aml_v4l2src_streamon:373]Enter
[API:aml_v4l2src_streamon:376]Exit
0:00:02.442164872  3982   0x7f880012f0 FIXME           videodecoder gstvideodecoder.c:1193:gst_video_decoder_drain_out:<jpegdec0> Sub-class should implement drain()
0:00:02.442706696  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src0> Can't give latency since framerate isn't fixated !
Pipeline is live and does not need PREROLL ...
0:00:02.442761196  3982   0x7f880014d0 FIXME           videodecoder gstvideodecoder.c:1193:gst_video_decoder_drain_out:<jpegdec1> Sub-class should implement drain()
0:00:02.442916610  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src1> Can't give latency since framerate isn't fixated !
0:00:02.443112398  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:2283:gst_aggregator_query_latency_unlocked:<comp> Latency query failed
0:00:02.443481225  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src0> Can't give latency since framerate isn't fixated !
0:00:02.443626431  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src1> Can't give latency since framerate isn't fixated !
0:00:02.443736179  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:2283:gst_aggregator_query_latency_unlocked:<comp> Latency query failed
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
0:00:02.447227579  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src0> Can't give latency since framerate isn't fixated !
0:00:02.447410867  3982   0x7f88000d50 WARN                 v4l2src gstv4l2src.c:1005:gst_v4l2src_query:<v4l2src1> Can't give latency since framerate isn't fixated !
0:00:02.447522574  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:2283:gst_aggregator_query_latency_unlocked:<comp> Latency query failed
New clock: GstSystemClock
0:00:02.477358740  3982   0x7f880012f0 WARN                    v4l2 gstv4l2object.c:4802:gst_v4l2_object_set_crop:<v4l2src0:src> VIDIOC_S_CROP failed
0:00:02.478660343  3982   0x7f880014d0 WARN                    v4l2 gstv4l2object.c:4802:gst_v4l2_object_set_crop:<v4l2src1:src> VIDIOC_S_CROP failed
0:00:02.541860365  3982   0x7f880012f0 WARN                    v4l2 gstv4l2object.c:3472:gst_v4l2_object_reset_compose_region:<v4l2src0:src> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Invalid argument
0:00:02.543179718  3982   0x7f880014d0 WARN                    v4l2 gstv4l2object.c:3472:gst_v4l2_object_reset_compose_region:<v4l2src1:src> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Invalid argument
0:00:02.547730391  3982   0x7f880012f0 WARN          v4l2bufferpool gstv4l2bufferpool.c:853:gst_v4l2_buffer_pool_start:<v4l2src0:pool0:src> Uncertain or not enough buffers, enabling copy threshold
0:00:02.549753149  3982   0x7f880014d0 WARN          v4l2bufferpool gstv4l2bufferpool.c:853:gst_v4l2_buffer_pool_start:<v4l2src1:pool0:src> Uncertain or not enough buffers, enabling copy threshold
0:00:02.556557160  3982   0x7f880014d0 ERROR         v4l2bufferpool gstv4l2bufferpool.c:717:gst_v4l2_buffer_pool_streamon:<v4l2src1:pool0:src> error with STREAMON 28 (No space left on device)
0:00:02.556645992  3982   0x7f880014d0 ERROR             bufferpool gstbufferpool.c:572:gst_buffer_pool_set_active:<v4l2src1:pool0:src> start failed
0:00:02.557494103  3982   0x7f880014d0 WARN                 v4l2src gstv4l2src.c:968:gst_v4l2src_decide_allocation:<v4l2src1> error: Failed to allocate required memory.
0:00:02.557579851  3982   0x7f880014d0 WARN                 v4l2src gstv4l2src.c:968:gst_v4l2src_decide_allocation:<v4l2src1> error: Buffer pool activation failed
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src1: Failed to allocate required memory.
Additional debug info:
../sys/v4l2/gstv4l2src.c(968): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src1:
Buffer pool activation failed
0:00:02.558145758  3982   0x7f880014d0 WARN                 basesrc gstbasesrc.c:3397:gst_base_src_prepare_allocation:<v4l2src1> Subclass failed to decide allocation
0:00:02.558273339  3982   0x7f880014d0 WARN                 basesrc gstbasesrc.c:3177:gst_base_src_lExecution ended after 0:00:00.111846747
oop:<v4l2src1> error: Internal data stream error.
Setting pipeline to NULL ...
0:00:02.558352921  3982   0x7f880014d0 WARN                 basesrc gstbasesrc.c:3177:gst_base_src_loop:<v4l2src1> error: streaming stopped, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src1: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3177): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src1:
streaming stopped, reason not-negotiated (-4)
0:00:02.563403712  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:648:gst_aggregator_push_mandatory_events:<comp:src> Sending stream start event failed
0:00:02.563540668  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:658:gst_aggregator_push_mandatory_events:<comp:src> Sending caps event failed
0:00:02.563774789  3982   0x7f88000d50 WARN              aggregator gstaggregator.c:658:gst_aggregator_push_mandatory_events:<comp:src> Sending caps event failed
[API:aml_v4l2src_streamoff:381]Enter
[API:aml_v4l2src_streamoff:384]Exit
[API:aml_v4l2src_disconnect:363]Enter
change_divide_framerate, L69, dev , change_frame 0
[API:aml_v4l2src_disconnect:368]Exit
[API:aml_v4l2src_streamoff:381]Enter
[API:aml_v4l2src_streamoff:384]Exit
[API:aml_v4l2src_disconnect:363]Enter
change_divide_framerate, L69, dev , change_frame 0
[API:aml_v4l2src_disconnect:368]Exit
Freeing pipeline ...


Hello @DoomMonkey

Can you check on the command line with the commands below?

And please make sure the video node you choose is correct.

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=mmap ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec ! fakesink
gst-launch-1.0 v4l2src device=/dev/video1 io-mode=mmap ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec  ! fakesink

My cameras are on /dev/video0 and /dev/video2 and with that correction each of those commands works individually. My problem is that I cannot access both simultaneously

Ok, I figured it out. Unfortunately without patching the UVC kernel driver I will not be able to fix this and run two USB 2.0 webcams simultaneously.

This thread sums it up nicely: Use gstreamer to open two USB cameras, Failed to allocate required memory - Jetson Nano - NVIDIA Developer Forums

And looking at the schematic I can see that if the device is USB 2.0 plugged into the USB 3.0 slot it will use the same hub as the other 2.0 socket and will run into the limitation described in that link.

Hello @DoomMonkey

I checked two USB 2.0 UVC on my side and it works well.

Do you use two USB 3.0 UVC ? Please execute the commands below and provide the full logs and lsusb result.

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=mmap ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec ! fakesink
gst-launch-1.0 v4l2src device=/dev/video2 io-mode=mmap ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec  ! fakesink

Are you executing those commands individually? Or simultaneously? I can run those commands individually and see each camera one at a time. However, I cannot run them simultaneously. That is, open two terminals and execute both. I will attempt again and report the logs

Like I said, I can execute these individually but not simultaneously. If I login via ssh in one terminal and execute the first command it will run just fine. However, while that is running, if I login via another terminal and execute the second command while the first is running it will not run. If I kill (CTL-C) the first execution I can then successfully run the other.

Also my cameras are identical USB 2.0. lsusb -t can be found below as well.

Below is the output from the failing process:


USERNAME@vim4:~$ gst-launch-1.0 v4l2src device=/dev/video2 io-mode=mmap ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec ! fakesink
Setting pipeline to PAUSED ...
[API:aml_v4l2src_connect:271]Enter, devname : /dev/video2
driver : uvcvideo
device : Global Shutter Camera: Global S
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
strcmp cap.driver: uvcvideo
[API:aml_v4l2src_connect:298]Exit, USB camera
devname : /dev/video2
driver : uvcvideo
device : Global Shutter Camera: Global S
bus_info : usb-xhci-hcd.0.auto-1.2
version : 331639
error tvin-port use -1
[API:aml_v4l2src_streamon:373]Enter
[API:aml_v4l2src_streamon:376]Exit
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.
Additional debug info:
../sys/v4l2/gstv4l2src.c(968): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Buffer pool activation failed
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Execution ended after 0:00:00.109946997
Additional debug info:
../libs/gst/base/gstbasesrc.c(3177): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Setting pipeline to NULL ...
[API:aml_v4l2src_streamoff:381]Enter
[API:aml_v4l2src_streamoff:384]Exit
[API:aml_v4l2src_disconnect:363]Enter
change_divide_framerate, L69, dev , change_frame 0
[API:aml_v4l2src_disconnect:368]Exit
Freeing pipeline ...

 lsusb -t
/:  Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci-hcd/1p, 480M
    |__ Port 001: Dev 002, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 001: Dev 003, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 001: Dev 003, If 1, Class=Video, Driver=uvcvideo, 480M
        |__ Port 002: Dev 004, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 002: Dev 004, If 1, Class=Video, Driver=uvcvideo, 480M
/:  Bus 002.Port 001: Dev 001, Class=root_hub, Driver=xhci-hcd/1p, 10000M

Running simultaneously and works well.

I checked with image vim4-ubuntu-22.04-gnome-linux-5.15-fenix-1.6.9.1-240815-develop-test-only.img.xz, you can install it with oowow online.

I have install the OS image as you suggested and still the same problem. So the only difference would be our cameras. Can you run “lsusb -t” and report back?

I replaced just one of my cameras with a different webcam, a Logitech, and then both pipelines run simultaneously. I am glad to see this works but I am still confused as to why the two identical cameras did not work. Both are MJPEG streaming.

Could you share the camera model to us?

This is the camera which I was not successful in running 2 simultaneously: