Webcam fails after a while, discovered port conflict upon webcamd restart

What is the problem?
The webcam fails after a while, and only restarting the PI seems to fix the issue. Except that lately it seems to like to fail after a print has started, and right when I need to leave the room. Obviously can't restart the Pi then. I did a fair amount of debug (detailed below). It appears it's conflicting with OctoPrint. How can that be?

What did you already try to solve it?
I've done some digging and here's what I know:

  1. Accessing it directly via http://octopi.local:8080/webcam/?action=stream only shows a 404
  2. The logs (via journalctl -u webcamd) are shown below. Basically I'm just seeing that the camera starts (I see the physical light also come on), but the page does not change, and the log seems to indicate a port conflict on 8080
  3. I did a sudo netstat -lptn (results also below), found the offending process id, and ran ps. It appears that OctoPrint has something also running on 8080...

Logs
journalctl


Jan 09 11:31:30 octopi webcamd[6713]: config file='/boot/octopi.txt':USB device was not set in options, start MJPG-streamer with the first found video device:
Jan 09 11:31:30 octopi root[6736]: Starting USB webcam
Jan 09 11:31:30 octopi webcamd[6713]: <13>Jan  9 11:31:30 root: Starting USB webcam
Jan 09 11:31:30 octopi webcamd[6713]: Running ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -r 1920x1080 -f 15 -d /dev/video1
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: starting application
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
Jan 09 11:31:30 octopi webcamd[6713]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
Jan 09 11:31:30 octopi webcamd[6713]:  i: Using V4L2 device.: /dev/video1
Jan 09 11:31:30 octopi webcamd[6713]:  i: Desired Resolution: 1920 x 1080
Jan 09 11:31:30 octopi webcamd[6713]:  i: Frames Per Second.: 15
Jan 09 11:31:30 octopi webcamd[6713]:  i: Format............: JPEG
Jan 09 11:31:30 octopi webcamd[6713]:  i: TV-Norm...........: DEFAULT
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: Using V4L2 device.: /dev/video1
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: Desired Resolution: 1920 x 1080
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: Frames Per Second.: 15
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: Format............: JPEG
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: TV-Norm...........: DEFAULT
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_ADD - Error at Pan (relative): Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_ADD - Error at Tilt (relative): Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_ADD - Error at Pan Reset: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_ADD - Error at Tilt Reset: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_ADD - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_ADD - Error at Focus (absolute): Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Pan (relative): Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Tilt (relative): Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Pan Reset: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Tilt Reset: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Focus (absolute): Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at LED1 Mode: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at LED1 Frequency: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Disable video processing: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]: UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (25)
Jan 09 11:31:30 octopi webcamd[6713]:  o: www-folder-path......: ./www-octopi/
Jan 09 11:31:30 octopi webcamd[6713]:  o: HTTP TCP port........: 8080
Jan 09 11:31:30 octopi webcamd[6713]:  o: HTTP Listen Address..: (null)
Jan 09 11:31:30 octopi webcamd[6713]:  o: username:password....: disabled
Jan 09 11:31:30 octopi webcamd[6713]:  o: commands.............: disabled
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: www-folder-path......: ./www-octopi/
Jan 09 11:31:30 octopi webcamd[6713]: bind: Address already in use
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: HTTP TCP port........: 8080
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: HTTP Listen Address..: (null)
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: username:password....: disabled
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: commands.............: disabled
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: starting input plugin input_uvc.so
Jan 09 11:31:30 octopi mjpg_streamer[6737]: MJPG-streamer [6737]: starting output plugin: output_http.so (ID: 00)
Jan 09 11:31:31 octopi webcamd[6713]: Done bring up all configured video device
Jan 09 11:31:31 octopi webcamd[6713]: Goodbye...

netstat

tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      442/python2
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      442/python2

ps

 PID TTY      STAT   TIME COMMAND
  442 ?        Sl    47:20 /home/pi/oprint/bin/python2 /home/pi/oprint/bin/octoprint serve --host=127.0.0.1 --port=5000

Additional information about your setup
OctoPrint version:
OctoPi version:
Camera: Logitech 920
Plugins:

Action Command Prompt Support  
Announcement Plugin  
Anonymous Usage Tracking  
Application Keys Plugin  
Autoscroll (0.0.2)
Backup & Restore  
Bed Visualizer (0.1.11)
Core Wizard  
Discovery  
EEPROM Marlin Editor Plugin (1.2.1)
Error Tracking  
Exclude Region (0.2.0)
Floating Navbar (0.3.1)
Force Login  
Fullscreen Plugin (0.0.4)
GcodeEditor (0.2.7)
Logging  
Navbar Temperature Plugin (0.11)
OctoFlat Theme (0.2.0)
Octolapse (0.3.4)
Pi Support Plugin  
Plugin Manager  
Printer Safety Check  
PrintTimeGenius Plugin (2.2)
Sidebar Webcam (0.1.7)
Simple Emergency Stop (0.2.5)
Slicer (1.4.3)
SlicerSettingsParser (2.0.1)
SlicerSettingsTab (1.0.3)
Software Update  
Tab Order (0.5.5)
The Spaghetti Detective (1.0.8)
Themeify (1.2.0)
TouchUI (0.3.13)
Virtual Printer  
Webcam Tab (0.1.2)

Are you using the 25FPS streaming option on The Spaghetti Detective. If so it uses a different webcam streaming service that overrides Webcamd

Hmm... I have a self hosted instance... haven't seen that option. Let me check. I didn't see it in the plugin itself...

If it's the options mentioned here: https://www.thespaghettidetective.com/docs/more-about-webcam-streaming/#webcam-streaming-causing-issues

Then it's unchecked currently.

If this does cause a conflict, can you make the built in webcam use theirs instead?

Check the box and then reboot the raspberry pi and check back if that works

Webcam seems solid. It's a shame that I can't use TheSpaghettiDetective though.

You can still use the detective! The 25fps streaming just won't work. If you want help troubleshooting this further you can ask for help in our Discord! https://discord.gg/hsMwGpD