31
16
Running more than one USB webcam in Debian/Linux results in the the following error:
libv4l2: error turning on stream: No space left on device
VIDIOC_STREAMON: No space left on device
What initially seemed to be a programming issue in OpenCV turned into a quest for a mysterious hardware/software problem after the same errors were produced by running cheese and xawtv.
Apparently it's caused by webcams requesting all the available bandwidth on the USB host controller. With that in mind I decided to run wireshark and capinfos to see just how much bandwidth a single camera used.
4 megabits per second at 320x240
14 megabits per second at 640x480
32 megabits per second at 1280x720
Interesting! That might explain why two cameras at 320x240 work but any higher resolution fails. It's as if my USB controller is only operating at USB 1 speeds, yet lsusb shows both webcams belonging to a device which supposedly supports 480 megabits per second.
One solution proposed forcing the webcams to calculate their bandwidth usage instead of requesting their maximum by running the following commands:
sudo rmmod uvcvideo
sudo modprobe uvcvideo quirks=128
Unfortunately that made no difference, so I decided to try another solution. A post on StackOverflow suggested telling my webcams to use a lower FPS or compressed video format like MJPEG, but after running v4lctl list it doesn't appear either of my webcams support changing their video mode.
And that's where I'm stuck. Why would two webcams operating well below the maximum speed of USB 2 would produce this error?
ps: It's not a disk space issue, df displays no change when the webcams are started.
pps: If it makes a difference, here's the output of lsusb
When using resolutions of 320x240 or lower, I get mixed results. I bought 4 cheap USB webcams, all of the same make/model. When trying to run 2 at 160x120, some of them would work fine together and some gave the memory error. I see no rhyme or reason to it. Granted, these webcams cost $3/each, so I guess I got what I paid for. – Cerin – 2015-04-17T13:54:48.553
Connecting two or more of those cameras to USB3.0 works fine, even through a USB2.0 hub. Checked with YUYV. – Michał Leon – 2016-12-01T23:09:38.437
1Hi, if possible, can you tell me how I should set the pixel format of 2 cameras so that I can capture both at 640x480? I am using OpenCV and currently experiencing the same situation like you have where both cameras will only work at 320x240 or lower – lexma – 2012-12-04T21:30:01.283
Aha!
v4l2-ctl
is indeed an excellent tool for debugging. Found out a lot about my camera, and was able to fix the issue. Anyways, I was able to fix it by forcing my camera's resolution to320x240
and usingYUYV
as the camera output mode.guvcview
also helped a lot. – Sheharyar – 2014-03-22T20:48:36.403