How to get a USB camera to work?

What is the problem?
Getting a Microscope type USB camera to work. Mine is a Veho VMS-001.
What did you already try to solve it?
Checked the Webcam log and device log (udevadm output).
Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)

OctoPi .14 OctoPrint 1.3.6 Pi3B

Solution: Make sure the resolution and frame rate match the camera.
Make sure the aspect ratio matches in the OctoPrint settings.

I realize that the Web Camera stuff is supported through mjpg-streamer so my question is who do I go talk to? Him, or the OctoPi guy?
I’ve got one of the microscope type USB cameras which I think is perfect for this application as it gives me a zoomed up view of the printing region.
The RP3 is seeing the device, I’m guessing mpjg-streamer isn’t.

OctoPi .14
OctoPrint 1.3.6
RP3B

Here's the udevadm output for that device if it helps any:
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-
1.5:1.0':
KERNELS=="1-1.5:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="uvcvideo"
ATTRS{interface}=="Venus USB2.0 Camera"
ATTRS{iad_bInterfaceCount}=="02"
ATTRS{iad_bFunctionSubClass}=="03"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceSubClass}=="01"
ATTRS{bInterfaceClass}=="0e"
ATTRS{iad_bFirstInterface}=="00"
ATTRS{bAlternateSetting}==" 0"
ATTRS{authorized}=="1"
ATTRS{bNumEndpoints}=="01"
ATTRS{iad_bFunctionClass}=="0e"
ATTRS{supports_autosuspend}=="1"
ATTRS{iad_bFunctionProtocol}=="00"

Here's the WebCam.log:

Starting up webcamDaemon...

"--- Configuration: ----------------------------
camera: auto
usb options: -r 640x480 -f 10
raspi options: -fps 10
http options: -w ./www-octopi -n
-----------------------------------------------"

logger: Starting USB webcam
Running ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -r
640x480 -f 10
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 10
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
i: FPS coerced ......: from 10 to 15
i: Frame period time ......: 100 ms
UVCIOC_CTRL_ADD - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Mode: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Frequency: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Disable video processing: Inappropriate ioctl for dev
ice (25)
UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (2
5)
o: www-folder-path......: ./www-octopi/
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: disabled

Might be that your camera doesn't support mjpg natively. Check if the -y parameter makes it work:

https://discourse.octoprint.org/t/how-can-i-change-mjpg-streamer-parameters-on-octopi/203

Note that that will mean that your pi will have to transcode the video stream.

1 Like

-y didn't work.
The specs for the camera says it's TWAIN / VFW / Direct Show AP (Driver) compatible. Does that help?

For reference here is a list of UVC compliant cameras:
http://www.ideasonboard.org/uvc/#devices

There is a Veho VMS-004 device listed there. Mine is a VMS-001.

Does the frame rate have to match what the camera is putting out or is it just specifying what is output?

Some cameras will freak out if you try to force a framerate it doesn't support, the setting will try to set the framerate though, it's not like OctoPrint's baud setting that has to match the printer's baud.

I'd try the common framerates, 10, 15, 25, 30 and see if that helps.

Otherwise, it looks like the camera is working from that log? maybe? I don't see any "camera not found" and all those other errors are fairly common.

You could try stopping the mjpeg server, then start it manually with various parameters to see if any of them work for you. I've seen some people say the only way to get it to work is to modify the script that runs mjpeg streamer and remove the default framerate switch because trying to set any kind of frame rate caused the camera to fail.

1 Like

Do you know the commands to manually stop and start the streamer?

to stop the service sudo service webcamd stop I believe (I don't actually use octopi, I have it all manually installed) and the command to manually start it with parameters is in the install wiki https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian#webcam

I think you'll need

cd ~/mjpg-streamer
export LD_LIBRARY_PATH=.
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so"

Again, not sure on those paths exactly because I don't use octopi.

1 Like

Ok. Changing the frame rate to 15 seems to have done something.
I get a picture when I access the stream directly in a separate window but it doesn't show up under OctoPrint.. It is also extremely lagged maybe 2 minutes worth!

The camera stream isn't really what I'd call wifi friendly and requires a lot of bandwidth, my wireless signal is pretty weak and the cam stream gets choppy, but when running on ethernet the stream is smooth. Check your wireless connection speed (also if it's a pi3, the built in wifi is utter garbage) and try moving the device around a bit for a better signal. I ended up shoving a wifi dongle on the end of a 3m long usb cable & hanging it on a door knob in the hallway, worked great after that.

1 Like

I finally got it to show in OctoPrint, needed the aspect ratio to match. I’ve got both ethernet and WiFi enabled and working, is there a way to use both?
Force the mjpg-streamer to use ethernet?

I’ve got both ethernet and WiFi enabled and working, is there a way to use both?
Force the mjpg-streamer to use ethernet?

Short answer: yes

Long answer: it's complicated

It's much easier to just stick with one, if you can use ethernet then do so, it'll probably be more reliable than wifi. There's not much benefit from accessing octoprint's web pages via wifi and the cam stream over ethernet, you're better off just accessing both over the one (ethernet) connection and turn off wifi to keep it simple.