1

I have 5 HD Webcams (Creative Live Cam Sync 1080p) and want to stream the pictures with https://github.com/jacksonliam/mjpg-streamer on Debian Buster 4.19.0-11-amd64.

All of them support MJPG, as you can see in the picture.

Supported Formtats

The problem is that I can only start 3 mjpg-streamer due to a bandwidth limitation.

kernel.log says:

usb 3-2: Not enough bandwidth for new device state.
usb 3-2: Not enough bandwidth for altsetting 7

I'm starting the webcams with the command

/usr/local/bin/mjpg_streamer -i "/usr/local/lib/mjpg-streamer/input_uvc.so -d /dev/video0 -n -f 5 -r 1920x1080" -o "/usr/local/lib/mjpg-streamer/output_http.so -p 8085 -w /usr/local/share/mjpg-streamer/www"

mjpeg-streamer output

usbtop output:

 Device ID 2 :                 141.73 kb/s     15259.90 kb/s

This means that one webcam is using 15Mb/s or roughly 2MB/s. I am using USB 3.0, which supports 5Gbit/s.

I don't really understand where the problem is or what is going wrong. It seems that mjpeg-streamer is using the raw image data instead of the mjpeg stream.

1 Answers1

1

The specs of the Creative Live! Cam Sync 1080p list it as a USB 2.0 device. This means that the cameras only use the USB 2.0 controller that is also built into your USB 3.0 device, so you have much less available bandwidth than you think.

The theoretical bandwidth of a USB 2.0 Hub is 480mbps or ~60MBps. However, webcam data transfers are limited to 80% of this maximum, giving 384mbps. Dividing this bandwidth across 5 cameras gives 76.8mbps or 9.6 MB/s per camera, which is still much more than what you are observing.

Although the above calculation applies to the majority of webcams, some webcams do not play well and allocate bandwidth for large uncompressed frames, regardless of what data they actually transmit. It looks like your webcam is one of those.

For more info on this bug, and some possible workarounds, see the article Linux UVC driver and tools – FAQ. For the benefit of the readers, I quote below the list of workarounds, although not all apply to your cameras:

  • Disable other devices that allocate periodic transfer bandwidth. This includes keyboards, mice and microphone/speaker. The easiest way to disable audio devices is to blacklist the snd-usb-audio module.
  • Capture video in a compressed format. Many UVC devices support both uncompressed YUV and compressed MJPEG, switching from YUV to MJPEG should reduce bandwidth usage.
  • Reduce the frame size. Reducing the frame rate is unlikely to help given that images are often transferred in bursts regardless of the frame rate
  • Connect the cameras to different USB host controller. This effectively raised the total available bandwidth as each USB host controller can use 480 Mb/s. Note that connecting the cameras to separate hubs on a single USB host controller won't help here. Extra USB host controllers can be added to the system as cheap PCI cards.

One other workaround you could try is to downgrade the cameras to 720P.

See the article Using Multiple USB Cameras on a single USB Hub for a method that uses VLC to reduce the resolution or the frame rate in half. (I doubt that this method applies to your cameras.)

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • I've tried switching between mjpg and yuyv and also used different resolutions like 160 by 120 but the used bandwidth per webcam drops at most to 10Mbit/s which is still to high. Even with the modprobe uvcvideo quirks=640 hack I can still only use 3 Webcams. – ComanderKai77 Oct 16 '20 at 20:04
  • If physically possible, adding a USB card to the computer can solve the problem. Software-wise, which driver are you using? You might look at the [Linux UVC driver and tools](https://www.ideasonboard.org/uvc/) which lists some Creative Live! Cam models, but unfortunately not yours, but it might be newer than yours. I'm not on Linux, so can't help with the small details. – harrymc Oct 17 '20 at 05:54
  • I have three http://www.logilink.org/Produkte_LogiLink/Interface_Karten/Express_Karten/PCI_Express_Karte-4x_USB_30.htm?seticlanguage=en but I never really got them working. I can use a 3D printer with it but the webcams produce a bandwidth error. Even with only one webcam. Anyway, I will accept you answer because you provided specific details to the USB interface. – ComanderKai77 Oct 17 '20 at 10:46