stuart
2015-12-30 00:46:21 UTC
Hi,
I have had a lot of trouble in the past getting multiple webcams to work
on the one USB bus and I believe now that they were bandwidth related.
At present I am mostly using Logitech C270s and they are hopeless at
reporting the USB bandwidth that they need so only one camera will work
on a 480Mbit/s bus at 1280x960 and 10fps.
My testing has shown that a C270 running at 1280x960 produces MJPEGs
200kbytes big so in theory it should only need 10x200000x8 = 16Mbit/s
however it asks for 196Mbit/s.
I looked at the uvcvideo module and there is a quirks=128 module
parameter but is ignored if the stream is MJPEG compressed.
Let me first say that I think what I am proposing is ugly however I
can't think of anything better.
I have modified the uvcvideo module so that I can provide a
"compression" factor to the module through the V4L2 interface. It is a
"hacky" in that I used the priv attribute in the struct v4l2_pix_format
to specify the value. In the module I use the quirks=128 code to
calculate the size of the uncompressed image and then divide by the
compression factor to work out what USB bandwidth to use.
To protect innocent users of the "priv" attribute against an unexpected
"dead" camera I set the top bits of the priv attribute to to 0xfeed000
to identify it as a compression attribute. I did this because I know
nothing about what priv is used for. It seems wrong to put an explicit
attribute into the V4L2 interface but it would make this a lot cleaner.
I store the "bCompression" attribute in struct uvc_streaming structure
because I had trouble working out the lifespan of the other structures
used in the module.
By default I use a compression factor of 10 which allows a large margin
for if the camera encounters a particularly hard image to compress. The
C270 running at 1280x960 and 10fps now uses 41Mbit/s and I can easily
run 4 cameras on one bus.
The uvcvideo code I have attached is from Ubuntu 14.04. I am attaching
the original code and the modified code to allow a "diff -r".
If this proposal is unacceptable then I invite alternative suggestions
and I will look deeper into the uvcvideo code to find better ways of
implementing it if this will help.
Thank you for for this project because it has made so many webcams
usable with Linux.
I have had a lot of trouble in the past getting multiple webcams to work
on the one USB bus and I believe now that they were bandwidth related.
At present I am mostly using Logitech C270s and they are hopeless at
reporting the USB bandwidth that they need so only one camera will work
on a 480Mbit/s bus at 1280x960 and 10fps.
My testing has shown that a C270 running at 1280x960 produces MJPEGs
200kbytes big so in theory it should only need 10x200000x8 = 16Mbit/s
however it asks for 196Mbit/s.
I looked at the uvcvideo module and there is a quirks=128 module
parameter but is ignored if the stream is MJPEG compressed.
Let me first say that I think what I am proposing is ugly however I
can't think of anything better.
I have modified the uvcvideo module so that I can provide a
"compression" factor to the module through the V4L2 interface. It is a
"hacky" in that I used the priv attribute in the struct v4l2_pix_format
to specify the value. In the module I use the quirks=128 code to
calculate the size of the uncompressed image and then divide by the
compression factor to work out what USB bandwidth to use.
To protect innocent users of the "priv" attribute against an unexpected
"dead" camera I set the top bits of the priv attribute to to 0xfeed000
to identify it as a compression attribute. I did this because I know
nothing about what priv is used for. It seems wrong to put an explicit
attribute into the V4L2 interface but it would make this a lot cleaner.
I store the "bCompression" attribute in struct uvc_streaming structure
because I had trouble working out the lifespan of the other structures
used in the module.
By default I use a compression factor of 10 which allows a large margin
for if the camera encounters a particularly hard image to compress. The
C270 running at 1280x960 and 10fps now uses 41Mbit/s and I can easily
run 4 cameras on one bus.
The uvcvideo code I have attached is from Ubuntu 14.04. I am attaching
the original code and the modified code to allow a "diff -r".
If this proposal is unacceptable then I invite alternative suggestions
and I will look deeper into the uvcvideo code to find better ways of
implementing it if this will help.
Thank you for for this project because it has made so many webcams
usable with Linux.