Multiple web cams in Linux

The machine has two cameras currently:

One camera looks up, the other looks down.
It won’t always be held by rubber bands.

 

Yesterday I set out to see both cameras at the same time. Simple – they’re USB, I’ll just fire up two instances of VLC:

cvlc v4l2c:///dev/video0 :v4l2-width=640 :v4l2-height=480 :v4l2-fps=4&
cvlc v4l2c:///dev/video1 :v4l2-width=640 :v4l2-height=480 :v4l2-fps=4&

Well, one shows up. The other cvlc instance crashes. It turns out that some webcams claim the whole available USB bandwidth in isochronous mode. Being smarter than it needs to be, the computer decides that I wouldn’t be happy with choppy video, and the result is that I’m not allowed to see both video feeds at once.

Some web searches indicate that I might want to try changing to a compressed video mode such as MJPG. It would take up less bandwidth than whatever uncompressed mode it defaults to – so I tried changing the video mode to MJPG, using v4l2-ctl:

v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=MJPG -d /dev/video1
v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=MJPG -d /dev/video0

There’s also an option to set MJPG when invoking vlc itself, however I can’t remember it at the moment, and it doesn’t matter because it didn’t work. It’s likely I will settle for taking individual snapshots with vlc and bringing them into OpenCV. I’m not quite at that point yet, but I’ll update when I am.

One thought on “Multiple web cams in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *


× 9 = seventy two

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>