How to find out which process is using the V4L2 webcam

cameradevicesv4lvlc

I tried to run the following:

$ vlc -I dummy v4l2:///dev/video0 --video-filter scene --no-audio --scene-path webcam.png --scene-prefix image_prefix --scene-format png vlc://quit --run-time=1                                                     
VLC media player 2.0.7 Twoflower (revision 2.0.6-54-g7dd7e4d)                                                                                                                                                                                                             
[0x1f4a1c8] dummy interface: using the dummy interface module...                                                                                                                                                                                                          
[0x7fc19c001238] v4l2 demux error: VIDIOC_STREAMON failed                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
libv4l2: error setting pixformat: Device or resource busy                                                                                                                                                                                                                 
[0x7fc19c007f18] v4l2 access error: cannot set input 0: Device or resource busy                                                                                                                                                                                           
[0x7fc19c007f18] v4l2 access error: cannot set input 0: Device or resource busy                                                                                                                                                                                           
[0x7fc1a4000b28] main input error: open of `v4l2:///dev/video0' failed                                                                                                                                                                                                    
[0x7fc1a4000b28] main input error: Your input can't be opened                                                                                                                                                                                                             
[0x7fc1a4000b28] main input error: VLC is unable to open the MRL 'v4l2:///dev/video0'. Check the log for details.                                                                                                                                                         
[0x7fc19c007cc8] idummy demux: command `quit'    

So I'm assuming that there is a program currently accessing my webcam, which is cumbersome since its light is off and lsof | grep /dev/video returns nothing. Is there another, proper way to check what processes are currently using my webcam? Or is the problem of an entirely different nature?

Best Answer

I was having the same problem and the solution at http://www.theoutpost.org/8-nslu2/open-devvideo0-device-or-resource-busy/ (EDIT: url updated) helped me.

$ fuser /dev/video0
/dev/video0: 1871m
$ ps axl | grep 1871
$ kill -9 1871
Related Question