Webcam Stops Streaming Randomly


#1

I have been having an issue where my webcam stops working randomly. I have checked lsusb and it shows up there and I have tried to unplug and plug it back in and it won’t come back until I reboot the Pi. I am not sure where else to look for a possible solution. Below is the webcam I am using.


#2

Is this a Raspberry Pi 3B or a Raspberry Pi Zero or something else?


#3

Also, have you tried the camera on another device to make sure the webcam itself doesn't stop working randomly? The 2 biggest culprits here are likely to be power and temp on the Pi, but if your webcam does this on a laptop or desktop too, we're probably not going to have a solution. It'll also be useful for us to know how your Pi is connected to your network.


#4

It’s a Raspberry Pi 3.


#5

It may have been my power supply. I have replaced it and testing.


#6

For future reference, I give some details on how to check for power and temperature events in this post:


#7

Well it looks like it might not be the power supply after all. I am since replaced the power supply with a known good power supply that I have used with many other Raspberry Pi's and I am still getting webcam disconnects.

I ran the command vcgencmd get_throttled during this last disconnect and this is the output from that command throttled=0x0.

Thanks


#8

There appears to be issues here and here on the author's github. I've read it through and the author is attempting to deal with some logic which behaves badly in circumstances where the driver is taking too long to respond.

It may be necessary for @foosel and @guysoft to pull in a newer/fixed version but it would need to be pulled in by you by re-imaging with some new OctoPi image if it is indeed the fix. If you were a coder, I might suggest that you could attempt to rebuild your mjpg-streamer from the latest code.


#9

Nightly should be pulling the latest, I can have a look and confirm that later today.


#10

I think the current OctoPi image (0.15.1) should already have a version of mjpgstreamer with the patch in question as it was made in January and the image was compiled in May based on whatever was current then on the mjpgstreamer repo in question. Even OctoPi 0.15.0 should have it.


#11

Thanks.

I think next, I would attempt to lower the resolution to something small and see if the incidents go down. It's possible that under low-RAM situations, there's a lot of swapping that's slowing down the response.


#12

The latest on this issue is when it does stop streaming I can go into the processes and kill the process related to the mjpgstreamer and it will restart itself and start working again. If I don't do that I have to restart the Pi in order to get the image back. Looking at the logs the webcam never looses connectivity its more like the mjpgstreamer process gets hung.


#13

You mean, like this issue?


#14

No I am not using HDMI. I am just using a standard webcam listed on the known good webcam list and I have 2.5A power supply on the PI and randomly during prints the webcam will just stop streaming. The webcam doesn't appear to loose connectivity with the PI and in order for me to get it back without rebooting the PI is to kill the ./mjpg_streamer -o output_http.so -w ./www -i input_uvc.so -r 1920x1080 -f 30 process.


#15

@556duckvader And yet, it's a (closed) issue on the mjpg_streamer's github which reasonably behaves in the way you're describing. If your webcam is replying with a null buffer at some point, it could be landing in an area of code which hasn't been thoroughly tested nor expected.


#16

So would this be something that is webcam specific or with Octoprint? I didn’t have this problem until I updated Octoprint.


#17

I suppose that depends upon how you updated. If you used a new OctoPi image, it's possible that you got a newer mjpg_streamer.

If the webcam is sending back null at times, it does though sound like the webcam itself.

I really couldnt tell you.