guysoft / OctoPi

Scripts to build OctoPi, a Raspberry PI distro for controlling 3D printers over the web
GNU General Public License v3.0
2.49k stars 369 forks source link

USB webcam not working on startup #626

Open ScruffR opened 4 years ago

ScruffR commented 4 years ago

What were you doing?

After a SD card crash I finally got round to upgrading to the lates release but noticed that my Logitech Pro 9000 didn't work.

What did you expect to happen?

Of course I expected the webcam stream to show

What happened instead?

but it only ever keeps displaying this image for hours on end

Did the same happen when running OctoPrint in safe mode?

Yes, just the same.

Version of OctoPi

I'm running image on a RPi 3B+

Printer model & used firmware incl. version

although irrelevant for the issue at hand: Creality CR-10

Screenshot(s)/video(s) showing the problem:

see "What happened instead?"

I have read the FAQ.

However, I found that doing this resolves the issue till next reboot

sudo systemctl restart webcamd

After boot systemctl status webcamd reports this

● webcamd.service - the OctoPi webcam daemon with the user specified config
   Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-01-13 04:30:48 GMT; 1 day 4h ago
 Main PID: 440 (mjpg_streamer)
    Tasks: 5 (limit: 2077)
   Memory: 3.7M
   CGroup: /system.slice/webcamd.service
           └─440 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -r 640x480 -f 10 -d /dev/video0

Jan 13 04:30:57 octopi mjpg_streamer[440]: MJPG-streamer [440]: HTTP TCP port........: 8080
Jan 13 04:30:57 octopi mjpg_streamer[440]: MJPG-streamer [440]: HTTP Listen Address..: (null)
Jan 13 04:30:57 octopi mjpg_streamer[440]: MJPG-streamer [440]: username:password....: disabled
Jan 13 04:30:57 octopi mjpg_streamer[440]: MJPG-streamer [440]: commands.............: disabled
Jan 13 04:30:57 octopi mjpg_streamer[440]: MJPG-streamer [440]: starting input plugin input_uvc.so
Jan 13 04:30:57 octopi mjpg_streamer[440]: MJPG-streamer [440]: starting output plugin: output_http.so (ID: 00)
Jan 13 04:31:02 octopi webcamd[345]:  i: select() timeout
Jan 13 04:31:02 octopi webcamd[345]:  i: cleaning up resources allocated by input thread
Jan 13 04:31:02 octopi mjpg_streamer[440]: MJPG-streamer [440]: select() timeout
Jan 13 04:31:02 octopi mjpg_streamer[440]: MJPG-streamer [440]: cleaning up resources allocated by input thread

and after the restart this

● webcamd.service - the OctoPi webcam daemon with the user specified config
   Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-01-14 09:20:51 GMT; 19s ago
  Process: 4148 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
 Main PID: 4173 (mjpg_streamer)
    Tasks: 4 (limit: 2077)
   Memory: 1.3M
   CGroup: /system.slice/webcamd.service
           └─4173 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -r 640x480 -f 10 -d /dev/video0

Jan 14 09:20:50 octopi mjpg_streamer[4173]: MJPG-streamer [4173]: HTTP Listen Address..: (null)
Jan 14 09:20:50 octopi webcamd[4148]:  o: username:password....: disabled
Jan 14 09:20:50 octopi mjpg_streamer[4173]: MJPG-streamer [4173]: username:password....: disabled
Jan 14 09:20:50 octopi webcamd[4148]:  o: commands.............: disabled
Jan 14 09:20:50 octopi mjpg_streamer[4173]: MJPG-streamer [4173]: commands.............: disabled
Jan 14 09:20:50 octopi mjpg_streamer[4173]: MJPG-streamer [4173]: starting input plugin input_uvc.so
Jan 14 09:20:50 octopi mjpg_streamer[4173]: MJPG-streamer [4173]: starting output plugin: output_http.so (ID: 00)
Jan 14 09:20:51 octopi webcamd[4148]: Done bring up all configured video device
Jan 14 09:20:51 octopi webcamd[4148]: Goodbye...
Jan 14 09:20:51 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.

After that the stream works even after a restarting OctoPrint - however when rebooting the RPi the problem reoccures.

Could a delayed start of webcamd be a possible solution?

cparsonscan commented 4 years ago

I wanted to chime in and add that I too have the same issue with the same temporary resolution of : pi@octopi:~ $ sudo systemctl restart webcamd

Using Logitech 902 USB Camera

octopi.txt Camera="USB" (Attempted "auto" to no better results)

The result from Control tab image "Webcam Stream Loading...." (To No Avail.)

Loging in after reboot:

OctoPrint version : 1.4.2 OctoPi version : 0.17.0

pi@octopi:~ $ systemctl status webcamd

● webcamd.service - the OctoPi webcam daemon with the user specified config
   Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-08-22 18:59:25 BST; 2min 46s ago
  Process: 355 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
 Main PID: 431 (mjpg_streamer)
    Tasks: 4 (limit: 2077)
   Memory: 3.6M
   CGroup: /system.slice/webcamd.service
           └─431 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -r 640x480 -f 10 -d /dev/video0

Aug 22 18:59:24 octopi mjpg_streamer[431]: MJPG-streamer [431]: commands.............: disabled
Aug 22 18:59:24 octopi mjpg_streamer[431]: MJPG-streamer [431]: starting input plugin input_uvc.so
Aug 22 18:59:24 octopi mjpg_streamer[431]: MJPG-streamer [431]: starting output plugin: output_http.so (ID: 00)
Aug 22 18:59:25 octopi webcamd[355]: Done bring up all configured video device
Aug 22 18:59:25 octopi webcamd[355]: Goodbye...
Aug 22 18:59:25 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Aug 22 18:59:29 octopi webcamd[355]:  i: select() timeout
Aug 22 18:59:29 octopi webcamd[355]:  i: cleaning up resources allocated by input thread
Aug 22 18:59:29 octopi mjpg_streamer[431]: MJPG-streamer [431]: select() timeout
Aug 22 18:59:29 octopi mjpg_streamer[431]: MJPG-streamer [431]: cleaning up resources allocated by input thread
pi@octopi:~ $

pi@octopi:~ $ sudo systemctl restart webcamd pi@octopi:~ $ systemctl status webcamd

● webcamd.service - the OctoPi webcam daemon with the user specified config
   Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-08-22 19:03:32 BST; 17s ago
  Process: 763 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
 Main PID: 787 (mjpg_streamer)
    Tasks: 4 (limit: 2077)
   Memory: 1.4M
   CGroup: /system.slice/webcamd.service
           └─787 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -r 640x480 -f 10 -d /dev/video0

Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: www-folder-path......: ./www-octopi/
Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: HTTP TCP port........: 8080
Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: HTTP Listen Address..: (null)
Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: username:password....: disabled
Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: commands.............: disabled
Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: starting input plugin input_uvc.so
Aug 22 19:03:31 octopi mjpg_streamer[787]: MJPG-streamer [787]: starting output plugin: output_http.so (ID: 00)
Aug 22 19:03:32 octopi webcamd[763]: Done bring up all configured video device
Aug 22 19:03:32 octopi webcamd[763]: Goodbye...
Aug 22 19:03:32 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
pi@octopi:~ $
guysoft commented 4 years ago

Not sure what is causing it at first glance, perhaps the video device takes longer to start. Sounds like a timing issue in general.

Maybe that service should start after octoprint @foosel ?

tablatronix commented 4 years ago

Same issue, stopped working a while ago, not sure why, just got around to debugging and tried this and it works.

dragonfly4 commented 3 years ago

Same issue on 0.18 RC1 Spent 2 hours for nothing so thanks for the workaround :-)

derkork commented 3 years ago

Running OctoPi 0.18.0 / OctoPrint 1.6.1, having the same issue with a Logitech QuickCam Pro 9000. Restarting webcamd fixes it here as well.

GitFunkee commented 2 years ago

Brilliant! The restart fixed my issue as well.