Is there a terminal command that lists all the webcams connected to my computer including the native one? Maybe using the ffmpeg package?

  • <<<<< lsusb >>>> – Qasim Sep 22 '13 at 20:33

To list all video devices picked up by the kernel

ls -ltrh /dev/video*

To list all devices attached to USB use lsusb ; to list all devices attached to PCI use lspci

| improve this answer | |
  • 1
    $ ls -ltrh /dev/video* ls: cannot access '/dev/video*': No such file or directory – Mona Jalal Jun 21 '18 at 21:11
  • @MonaJalal That means it couldn’t find any devices. – JMY1000 Jan 25 '19 at 22:23
  • this does not work on my surface pro 3. I can use cheese and it detects my camera just fine but lspci and the command above both do not show information about the webcam hardware. This is especially important because I want to use Kamera which asks to select from a long list. – Joshua Robison Mar 12 '19 at 0:13
  • The "-ltrh" in the "ls" command seems to be a bit of overkill "ls -l /dev/video*" should suffice. The -"t" sorts by time, the "-r" reverses the sort order and the "-h" gives you "human readable" sizes -- none of which appear very helpful here. Not harmful, but unnecessary. – Ubuntourist Oct 24 at 12:36

v4l2-ctl --list-devices

sudo apt-get install v4l-utils
v4l2-ctl --list-devices

Sample output with a single camera:

Integrated Camera (usb-0000:00:1a.0-1.6):

Tested on Ubuntu 16.04.

On Ubuntu 19.10 Lenovo Thinkpad P51 however, it lists two such devices, video0 and video1, but I only have one camera, and can only see images from video0 with ffplay. This has been asked at:

What happens is that /dev/video1 contains some kind of video metadata only and not the images as can been seen from:

sudo v4l2-ctl --device=/dev/video0 --all
sudo v4l2-ctl --device=/dev/video1 --all

which shows respectively:

        Device Caps      : 0x04200001
                Video Capture 

        Device Caps      : 0x04a00000
                Metadata Capture

How to see the camera image:

My favorite:

sudo apt install ffmpeg
ffplay /dev/video0

enter image description here

How to do it form C/C++: https://stackoverflow.com/questions/4290834/how-to-get-a-list-of-video-capture-devices-web-cameras-on-linux-ubuntu-c

A concrete C++ example that processes images from the camera on the GPU with OpenGL and shows it live: https://stackoverflow.com/questions/13693946/image-processing-with-glsl-shaders/40641014#40641014

enter image description here

How to get camera parameters like resolution:

| improve this answer | |
  • 5
    On 16.04.1 error: Failed to open /dev/video0: No such file or directory – Xaqron Jan 3 '17 at 16:41
  • 1
    Just because I keep coming back to this answer, it's now: v4l2-ctl --list-devices. That's lower in the answer but the top in bold text doesn't have the 2. – ksclarke Oct 11 '17 at 16:40
  • 1
    $ v4l2-ctl --list-devices Failed to open /dev/video0: No such file or directory – Mona Jalal Jun 21 '18 at 21:11
  • 1
    Beware that it says 4l2, not 412. (Unrelated to other comments.) – dremodaris Jul 17 '18 at 14:01
  • 2
    this is the correct actual answer. Thank you. – Joshua Robison Mar 12 '19 at 0:15

For Windows you can use the pygrabber library: https://github.com/bunkahle/pygrabber

To check the user friendly names of the connected webcams:

from __future__ import print_function
from pygrabber.dshow_graph import FilterGraph

graph = FilterGraph()
| improve this answer | |

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.