Camera streams mjpeg natively. Can I bypass whatever mjpg-streamer's doing?

mjpg-streamer periodically starts dropping frames like crazy, even though I'm on a high-bandwidth wifi connection, and CPU and memory use are not pegged - not even close.

Others have seen this problem with mjpg streamer, and the dev can't isolate the problem.

Since the camera already outputs an mjpeg stream, is there any reason I can't direct that directly into the Octoprint UI? Any pointers to getting started?

Camera model
Nexigo 980P USB web cam, formats from 320x240 to 60P HD, streaming from index0: RGB mjpeg stream.

What is the problem?
Camera already outputs mjpeg stream. Can I bypass mjpg-streamer?
Camera works beautifully - except when it doesn't - there's a likely mjpg-streamer issue, which others have reported.

What did you already try to solve it?
Tuning camera settings to try to prevent mjpg slowdown

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support)

webcamd.log

Starting up webcamDaemon...

ls: cannot access '/boot/octopi.conf.d/*.txt': No such file or directory
--- Configuration: ----------------------------
cfg_file: /boot/octopi.txt
camera: usb
usb options: -r 1280x720 -f 10 -d /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._NexiGo_HD_Webcam_SN0001-video-index0
raspi options: -fps 10
http options: -w ./www-octopi -n --listen 127.0.0.1

Explicitly set USB device: /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._NexiGo_HD_Webcam_SN0001-video-index0

Found video devices:
/dev/video0
/dev/video1
/dev/video10
/dev/video11
/dev/video12
/dev/video13
/dev/video14
/dev/video15
/dev/video16
/dev/video18
/dev/video19
/dev/video20
/dev/video21
/dev/video22
/dev/video23
/dev/video31
config file='/boot/octopi.txt':USB device was set in options and found in devices, starting MJPG-streamer with the configured USB video device: /dev/video0
<13>Jan 20 14:42:08 root: Starting USB webcam
Checking for VL805 (Raspberry Pi 4)...

  • It seems that you don't have VL805 (Raspberry Pi 4).
    There should be no problems with USB (a.k.a. select() timeout)
    Running ./mjpg_streamer -o output_http.so -w ./www-octopi -n --listen 127.0.0.1 -i input_uvc.so -r 1280x720 -f 10 -d /dev/video0
    MJPG Streamer Version.: 2.0
    i: Using V4L2 device.: /dev/video0
    i: Desired Resolution: 1280 x 720
    i: Frames Per Second.: 10
    i: Format............: JPEG
    i: TV-Norm...........: DEFAULT
    i: FPS coerced ......: from 10 to 30
    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 device (25)
    UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (25)
    o: www-folder-path......: ./www-octopi/
    o: HTTP TCP port........: 8080
    o: HTTP Listen Address..: 127.0.0.1
    o: username:password....: disabled
    o: commands.............: disabled
    Done bringing up all configured video devices

syslog mjpeg-streamer lines:

Jan 20 03:33:39 nutrimatwifi streamer_select[433]: No streamer type is set. Defaulting to 'mjpeg'.
Jan 20 03:33:39 nutrimatwifi streamer_select[433]: Setting streamer type 'mjpeg'.


dmesg re: camera

[ 31.715687] cam-dummy-reg: disabling
[ 94.883651] usb 1-1.4: new high-speed USB device number 5 using xhci_hcd
[ 94.997142] usb 1-1.4: New USB device found, idVendor=3443, idProduct=980a, bcdDevice= 1.00
[ 94.997172] usb 1-1.4: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[ 94.997189] usb 1-1.4: Product: NexiGo HD Webcam
[ 94.997204] usb 1-1.4: Manufacturer: Sonix Technology Co., Ltd.
[ 94.997217] usb 1-1.4: SerialNumber: SN0001
[ 95.073303] usb 1-1.4: Found UVC 1.00 device NexiGo HD Webcam (3443:980a)
[ 95.078896] input: NexiGo HD Webcam: NexiGo HD Web as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input2
[ 95.079327] usbcore: registered new interface driver uvcvideo
[ 95.119806] usb 1-1.4: 3:1: cannot get freq at ep 0x84
[ 95.165614] usbcore: registered new interface driver snd-usb-audio

Additional information about your setup (OctoPrint version, OctoPi version, ...)

OctoPi bullseye v1.0.0

OctoPrint 1.8.6

Raspberry Pi 4 Model B Rev 1.1, 4GB RAM

I doubt your camera streams mjpg natively over the network just from being plugged in - perhaps you are seeing that it outputs mjpg video?

You still need a way to get the information streamed over the network to embed it in OctoPrint's UI. It must be streamed. Mjpg streamer is not using much CPU because it's not doing any encoding of the frames, just streaming them, because of your camera outputs mjpg.

You can try different streaming software if you would like - for example ustreamer. Disable the webcamd service & install it as per it's instructions.

Thanks very much, and you're quite correct.

After a bunch of fooling around, I got ustreamer working nicely at 1280x1024.

Interestingly, ustreamer seems to be able to stream 1920x1080 to a browser, but not through Octoprint (where it chokes and drops frames). I'm using the camera's native compression. Not sure what's going on there.

Sometimes the browser struggles to keep up with the webcam due to the number of changes happening in OctoPrint's UI - sometimes it struggles, especially with lots of plugins enabled. The frontend for OctoPrint is not always the most efficient. Most likely the case if it works OK to view it separately but not in OctoPrint.