Webcam Stops Streaming Randomly

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.

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

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.

It’s a Raspberry Pi 3.

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

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

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

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.

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

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.

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.

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.

You mean, like this issue?

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.

@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.

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

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.

I have accidentally found the solution that worked for me. I was trying to solve the problem and forced the camera to USB only in the octopi.txt. I also took off the -f 10 for the framerate. This caused my camera to not work at all. When reverting the changes, I decided to change the framerate from 10 to 20, just because I wanted smoother video, not because I thought it would fix the random stopping of the stream. But ever since I did that I have not had a single stream issue. Perhaps the cameras cannot handle the low framerate and stop transmitting? I dont know, but I do know it worked for me.
Hope this helps someone else!

my camera Logitech QuickCam Pro 5000.

2 Likes