52

I have a web camera on my T500 Thinkpad. I would like to know its supported resolutions. Is there a way to find it out by means of software (and without having to consult the documentation)?

2
51

If you have video4linux installed try this:

v4l2-ctl -d /dev/video0 --list-formats-ext

Specify your camera device with -d argument, however it can be ommited if you are convinced that there's only one video device connected.

You should get something like:

    ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'JPEG' (JFIF JPEG, compressed)
            Size: Discrete 320x240
            Size: Discrete 640x480

Source : How can I list the available video modes for a USB webcam in Linux?

1
  • 7
    First you need to install the utility: sudo apt-get install v4l-utils
    – sup
    Feb 21 '16 at 13:31
46

Two possible approaches:

Use any software which can interact with the webcam (eg, cheese), save an image and look at the resolution.

Examine the output of lsusb in a terminal, to find a line describing a webcam:

$ lsusb
Bus 001 Device 002: ID 5986:0241 Acer, Inc BisonCam, NB Pro
...

Then use the Bus and Device numbers to get more information on that device:

$ lsusb -s 001:002 -v | egrep "Width|Height"
    wWidth    640
    wHeight   480
    wWidth    1280
    wHeight   1024
...

Which should print the height, width pairs the camera is capable of - in this case, 1280x1024 plus some smaller ones.

4
  • Thanks, I got WWidth 640 WHeight 480 WWidth 320 WHeight 240 WWidth 800 WHeight 600 WWidth 1024 WHeight 600 WWidth 1024 WHeight 768 WWidth 1280 WHeight 800 WWidth 1280 WHeight 1024 WWidth 640 WHeight 480 WWidth 320 WHeight 240 WWidth 800 WHeight 600 WWidth 1024 WHeight 600 WWidth 1024 WHeight 768 WWidth 1280 WHeight 800 WWidth 1280 WHeight 1024 I guess I can assume that the highest combination is the physical resolution.
    – sup
    Nov 10 '12 at 9:48
  • 1
    What if it's not usb, but builtin?
    – NoBugs
    Aug 16 '16 at 1:10
  • 1
    @NoBugs built-in cameras are also usually connected via internal usb interfaces. Mine is internal, and still shows up on the lsusb list as "Sunplus Innovation Technology Inc."
    – Masoud
    Mar 16 '17 at 1:02
  • i see the camera show up with lsusb, but the -s option doesn't provide any additional info about it
    – Michael
    Apr 15 at 16:17
25

This is also possible with ffmpeg, which also gives information on the video encoding (e.g. raw vs mjpeg).

ffmpeg -f video4linux2 -list_formats all -i /dev/video0

Example output:

...
[video4linux2,v4l2 @ 0x7fa3a8000b40] Raw       :     yuyv422 :           YUYV 4:2:2 : 640x480 320x240 800x600 1024x600 1024x768 1280x800 1280x1024
[video4linux2,v4l2 @ 0x7fa3a8000b40] Compressed:       mjpeg :          Motion-JPEG : 640x480 320x240 800x600 1024x600 1024x768 1280x800 1280x1024
...
4
  • use ffmpeg if you have no X server running as an alternative Feb 18 '18 at 17:17
  • 2
    Thanks for the hint, ffmpeg is better/more generic.
    – sebix
    Feb 27 '18 at 17:19
  • Thanks for this answer. which is better than the ones above. In my case , I was confused by the previous answers as I couldn't use the best resolution, as advertised by the vendor (Dell). Now I understand I need to use the Compressed/mjpeg format to use the full resolution. Instead of the Raw/yuyv422 format. Compressed: mjpeg : Motion-JPEG : 1280x720 ... 640x480 . Raw : yuyv422 : YUYV 4:2:2 : 640x480 .
    – Chris
    Aug 16 at 13:58
  • It depends on the video software you are using which resolution/video feed is used. Some depend on the raw feed and you won't get the best output, you'd need to manually select a different source, if possible at all.
    – sebix
    Aug 17 at 14:29
9

If you have gstreamer installed with plugin gstreamer1.0-plugins-base-apps you can use gst-device-monitor-1.0 binary.

$ gst-device-monitor-1.0

example output:

Device found:

    name  : FHD Camera
    class : Video/Source
    caps  : video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 5/1, 3/1 };
            video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)5/1;
            video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)20/1;
            video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
            image/jpeg, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1, 1/1 };
            image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
            image/jpeg, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
            image/jpeg, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1;
    properties:
        udev-probed = true
        device.bus_path = platform-70090000.xusb-usb-0:2.1:1.0
        sysfs.path = /sys/devices/70090000.xusb/usb1/1-2/1-2.1/1-2.1:1.0/video4linux/video0
        device.bus = usb
        device.subsystem = video4linux
        device.vendor.id = 1bcf
        device.vendor.name = "Sunplus\\x20IT\\x20Co\\x20"
        device.product.id = 2286
        device.product.name = "FHD\ Camera"
        device.serial = Sunplus_IT_Co_FHD_Camera
        device.capabilities = :capture:
        device.api = v4l2
        device.path = /dev/video0
        v4l2.device.driver = uvcvideo
        v4l2.device.card = "FHD\ Camera"
        v4l2.device.bus_info = usb-70090000.xusb-2.1
        v4l2.device.version = 264588 (0x0004098c)
        v4l2.device.capabilities = 2216689665 (0x84200001)
        v4l2.device.device_caps = 69206017 (0x04200001)
    gst-launch-1.0 v4l2src ! ...

this is especially interesting because it shows possible resolutions and FPS and video-format (e.g. MJPEG/YUY2) required FPS can be reached with.

1
  • You can find it in gstreamer1.0-plugins-base-apps in apt based systems Apr 15 '20 at 22:26
1

This worked for me:

First get the Bus and Device ID:

lsusb

Which will print something like the following:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 011: ID 0ac8:3420 Z-Star Microelectronics Corp. Venus USB2.0 Camera
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In my case I have the Venus USB2.0 Camera attached. So now I run this command:

lsusb -s 001:011 -v | grep -E "Width|Height"

Which produces the following list:

wWidth                            640
wHeight                           480
wWidth                            352
wHeight                           288
wWidth                            320
wHeight                           240
wWidth                            176
wHeight                           144
wWidth                            160
wHeight                           120
wWidth                            800
wHeight                           600
wWidth                           1280
wHeight                           960
wWidth                           1280
wHeight                          1024
wWidth                           1600
wHeight                          1200
wWidth( 0)                       1600
wHeight( 0)                      1200
wWidth( 1)                        352
wHeight( 1)                       288
wWidth( 2)                        320
wHeight( 2)                       240
wWidth( 3)                        176
wHeight( 3)                       144
wWidth( 4)                        160
wHeight( 4)                       120
wWidth( 5)                        800
wHeight( 5)                       600
wWidth( 6)                       1280
wHeight( 6)                       960
wWidth( 7)                       1280
wHeight( 7)                      1024
wWidth( 8)                        640
wHeight( 8)                       480

Source: raymii.org

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.