17

I have 4 480p USB 2.0 cameras. Any idea why I can't stream 4 feeds at once?

I am using a VL817 USB hub for all the cameras. It seems not the problem of bandwidth as the average frame size for one camera is 600kb 30fps.

Any idea why it is limited to 2 cameras?

screencap

camera

Giacomo1968
  • 58,727

3 Answers3

37

I believe from the information you've given, that you are exceeding the bandwidth of a single USB 2.0 bus when you try to use a third camera of this type. Here's the calculation:

480p implies 640 * 480 = 307,200 pixels per frame.

At 8 bits per color channel that would normally be 24 bits per pixel, so 307,200 * 24 = 7,372,800 bits per frame.

But you said in the comments that your cameras are doing YUY2 a.k.a. YUV2, which means they are using 4:2:2 chroma subsampling to reduce bandwidth by throwing away some color data. Explaining chroma subsampling is beyond the scope of this Answer, but my calculations say the 4:2:2 subsampling mode reduces the bits per pixel by one-third, so each frame would be about 4,915,200 bits.

There are 8,192 bits per kilobyte (or, more precisely, per KibiByte), so 4,915,200 / 8,192 = 600 KiB. I think this checks out with your observation that each frame was "600kb"; I think wherever you got that 600 number for the frame size, it was reporting in KibiBytes, not kilobits.

So all of this so far indicates to me that your cameras are sending an uncompressed 480p30, 4:2:2 (YUY2/YUV2) video stream.

So each frame is 4,915,200 bits, * 30 fps = 147,456,000 bits per second. ~147 Mbps fits within USB 2.0's 480 Mbps raw signaling rate before overhead.

A second camera would double the total bandwidth usage on the USB bus, to 294,912,000 bits per second. That seems like it should still fit within USB 2.0's bus speed.

A third camera would bring the total bus bandwidth usage to 442,368,000 bits per second, which seems too close to 480,000,000 to fit, given USB's reputation for having a lot of overhead. If USB's overhead hits 8% or more, that third camera's stream won't fit.

As fellow SuperUser regular @sawdust noted in the comments, your USB device tree screenshot shows that your PC has two USB host controllers (two separate USB buses), so you might well be able to work around this problem by figuring out which USB ports are connected to which host controller, and connect two cameras to each controller, instead of trying to put all four cameras on a single USB 2.0 bus.

Toby Speight
  • 5,213
Spiff
  • 110,156
11

Your VL817 USB hub uses a USB 2.0 USB multi-tt hub. I cite from the last link:

About USB 2.0 Hubports, ... the upstream link on any of our USB 2.0 Hubports is 480 Mbps. The aggregate bandwidth of all ports on the hub cannot exceed 480 Mbps at any given instant.

Given the calculations others have provided, your USB Hub can support the bandwidth of maximum 2 of your cameras, before those 480 Mbps are saturated.

See also this other SuperUser answer, which basically says that you'll encounter the same issue on any USB hub. The USB 2.0 is a separate protocol from the USB 3.0 / 3.1 protocol (and is separate from the USB 4.0 protocol). This means that the USB controller of your PC establishes a USB 2.0 connection to any USB hub which is separate from the USB 3.0 connection. So, for any hub the total of any USB 2.0 connections cannot exceed 480 Mbps.

To resolve this bottleneck, you'll need to hook up two of your cameras to a different hub, or connect them directly to your PC, taking care that there are no more than 2 cameras per USB Root hub: according to USB tree view you provide, your PC has two USB root hubs. You might try-and-test to which ports you'll need to connect the webcams.

1NN
  • 10,044
5

The key problem is that a normal USB 3 hub* is actually two hubs in one box. The hub for high/full/low speed peripherals is entirely separate from the hub for superspeed peripherals.

So if all your perhiperals are USB 2, then a USB 3 hub doesn't help you get any more bandwidth. To get more bandwidth you generaly need to get the devices onto seperate USB host controllers.

Sometimes you can achieve that by rearranging ports. Your USB viewer shows two "controllers" but it may be that only one is exposed externally, or it may be that one "controller" is for full/low/high speed (aka USB 2) devices only and the other is for superspeed devices only.

If you have a desktop, then a way to be sure a device is on a different controller is to use a PCI or PCIe card for some of the cameras, if you are on an older laptop then expresscard can fill a similar role. On a newer laptop thunderbolt may be an option.

plugwash
  • 6,719