0

I am using fswebcam on a debian image on a rpi3 with a logitech webcam. Fswebcam works great... when it works. I've plugged in a powered USB to make sure it was not a power issue of some sort, but every other time I call the fswebcam command it results in an error message saying that /dev/video0 is busy. If I wait a few seconds and try again it works just fine. This pattern typically repeats where one attempt fails due to device busy, then the 2nd attempt works. I am not sure what to try anymore to resolve this - anyone else had this issue or know better what I might try?

2

I was having the same issue today, here are the steps I followed

First, make sure you're using a powered USB hub. We will be resetting the USB to force the OS to reload the webcam.

Start here and get the reset usb program: https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line

Now we're able to force the OS to reload the hub (and the webcam along with it)

My hub was coming up as two hubs, so I'm reseting both of them. My Device ID was 05e3:0608 replace this with your values in the script capture.sh

pi@raspberrypi:~/dina $ lsusb 
Bus 001 Device 065: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 001 Device 064: ID 046d:082c Logitech, Inc. 
Bus 001 Device 063: ID 046d:c326 Logitech, Inc. 
Bus 001 Device 062: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In a script called capture.sh, paste the following (Notice the back ticks ` before and after)

#!/bin/bash

`lsusb -d 05e3:0608 | head -n 1 | awk  '{print "sudo ./usbreset /dev/bus/usb/"$2"/"substr($4,0,4)}'`
`lsusb -d 05e3:0608 | tail -n 1 | awk  '{print "sudo ./usbreset /dev/bus/usb/"$2"/"substr($4,0,4)}'`

#Sleep to give the OS time to load the webcam
sleep 5

fswebcam images/image.jpeg

run chmod to allow execution of this script

chmod a+x capture.sh
./capture.sh

That should work reliably

  • Thanks for the help. I may have to go this route, it's just unfortunate that we have to rely on what is basically a workaround to force it to work properly. – SunnyC Dec 28 '17 at 17:48
  • Absolutely agreed, this is a complete hack of a workaround. I'm not sure why the Pi has such a hard time dealing with USB webcams. – Kennedy Dec 28 '17 at 21:48
0

I had the same issue with my Logitech C905 and was nearly giving up, but then I found the solution in a post on the raspberrypi.org forum :) https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=197089

The problem was fixed for my by adding the extra command dwc_otg.fiq_fsm_mask=0x3 in the file /boot/cmdline.txt.

The reason why I didn't find it earlier was that the post was about issues with ffmpeg and not fswebcam, but root cause seems to be the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.