Manual USB camera settings in Linux

35 Comments

There are many UVC compatible webcams most of them support full auto mode but only a few of these cameras provide extended manual white balance, gain and exposure control. Kurokesu C1 family (C1, C1 PRO, C1 MICRO), Logitech C920 and Brio are the ones that can be trusted.

There are few tools to work with USB cameras in Linux. Probably V4L2-CTL is the most advanced and recommended command line tool for advanced users.

Fresh Linux might be missing utility, install it with simple command:

sudo apt update
sudo apt-get install v4l-utils

Now let’s see what we have connected on USB port

> v4l2-ctl --list-devices
KurokesuC1_SN000803 (usb-0000:00:14.0-1):
        /dev/video0
        /dev/video1

HD Pro Webcam C920 (usb-3f980000.usb-1.2):
        /dev/video2

Note two interfaces for Kurokesu C1 camera – this is dual stream output. One video device is for regular YUYV/MJPEG compressed output another is for h.264. You can open both of them at the same time with different programs (for example h.264 for live streaming, MJPG for onboard recording or computer vision processing)

List available controls

Video for Linux V4L2 can report all available controls to single list. List is self explanatory with possible value ranges.

> v4l2-ctl -d /dev/video0 --list-ctrls

Kurokesu C1 family

                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast 0x00980901 (int)    : min=0 max=64 step=1 default=32 value=32
                     saturation 0x00980902 (int)    : min=0 max=128 step=1 default=64 value=64
                            hue 0x00980903 (int)    : min=-40 max=40 step=1 default=0 value=0
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
                          gamma 0x00980910 (int)    : min=72 max=500 step=1 default=100 value=100
                           gain 0x00980913 (int)    : min=0 max=100 step=1 default=0 value=0
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1
      white_balance_temperature 0x0098091a (int)    : min=2800 max=9300 step=1 default=4600 value=4600 flags=inactive
                      sharpness 0x0098091b (int)    : min=0 max=6 step=1 default=3 value=3
         backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute 0x009a0902 (int)    : min=1 max=10000 step=1 default=156 value=156 flags=inactive
         exposure_auto_priority 0x009a0903 (bool)   : default=0 value=0

Logitech C920

                     brightness (int)    : min=0 max=255 step=1 default=-8193 value=128
                       contrast (int)    : min=0 max=255 step=1 default=57343 value=128
                     saturation (int)    : min=0 max=255 step=1 default=57343 value=128
 white_balance_temperature_auto (bool)   : default=1 value=1
                           gain (int)    : min=0 max=255 step=1 default=57343 value=0
           power_line_frequency (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature (int)    : min=2000 max=6500 step=1 default=57343 value=4000 flags=inactive
                      sharpness (int)    : min=0 max=255 step=1 default=57343 value=128
         backlight_compensation (int)    : min=0 max=1 step=1 default=57343 value=0
                  exposure_auto (menu)   : min=0 max=3 default=0 value=3
              exposure_absolute (int)    : min=3 max=2047 step=1 default=250 value=250 flags=inactive
         exposure_auto_priority (bool)   : default=0 value=1
                   pan_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                  tilt_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                 focus_absolute (int)    : min=0 max=250 step=5 default=8189 value=0 flags=inactive
                     focus_auto (bool)   : default=1 value=1
                  zoom_absolute (int)    : min=100 max=500 step=1 default=57343 value=100

Logitech Brio 4K

                     brightness (int)    : min=0 max=255 step=1 default=128 value=128
                       contrast (int)    : min=0 max=255 step=1 default=128 value=128
                     saturation (int)    : min=0 max=255 step=1 default=128 value=128
 white_balance_temperature_auto (bool)   : default=1 value=1
                           gain (int)    : min=0 max=255 step=1 default=0 value=0
           power_line_frequency (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature (int)    : min=2000 max=7500 step=10 default=4000 value=2770 flags=inactive
                      sharpness (int)    : min=0 max=255 step=1 default=128 value=128
         backlight_compensation (int)    : min=0 max=1 step=1 default=1 value=1
                  exposure_auto (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute (int)    : min=3 max=2047 step=1 default=250 value=625 flags=inactive
         exposure_auto_priority (bool)   : default=0 value=1
                   pan_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                  tilt_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                 focus_absolute (int)    : min=0 max=255 step=5 default=0 value=20 flags=inactive
                     focus_auto (bool)   : default=1 value=1
                  zoom_absolute (int)    : min=100 max=500 step=1 default=100 value=100
                      led1_mode (menu)   : min=0 max=3 default=0 value=3
                 led1_frequency (int)    : min=0 max=255 step=1 default=0 value=0

Reading current value

Read current UVC value with command below. Actual value is reported back below.

> v4l2-ctl --get-ctrl=white_balance_temperature
white_balance_temperature: 4600

Setting new value

In order to set new camera parameter value use command syntax like this:

> v4l2-ctl --set-ctrl=gain=00
> v4l2-ctl --set-ctrl=exposure_auto=1
> v4l2-ctl --set-ctrl=exposure_absolute=10

In some cases it is necessary to switch parameters in certain order for parameter to be set. For example change manual white balance control before setting fixed value:

> v4l2-ctl --set-ctrl=white_balance_temperature_auto=1
> v4l2-ctl --set-ctrl=white_balance_temperature=6000
VIDIOC_S_CTRL: failed: Input/output error
white_balance_temperature: Input/output error

> v4l2-ctl --set-ctrl=white_balance_temperature_auto=0
> v4l2-ctl --set-ctrl=white_balance_temperature=6000

Kurokesu C1 extension unit and firmware customization

Besides standard UVC control it is possible to customize Kurokesu C1 family camera firmware to meet specific customer needs, for example:

  • Set default UVC control values
  • Edit de-noise parameters
  • Edit USB frame size
  • Edit MJPEG compression rate
  • Edit h.264 bitrate
  • Set low light behavior (lower down to 2 frames per second automatically or maintain stable frame rate)
  • and much more

Camera Extension Unit is designed for Linux and allows to alter even more controls not covered by UVC protocol (for example: spot/center/frame measuring mode).

Comments ( 35 )

  1. ReplyJoão Natividade
    Hi there! As I verified, this camera doesn't appear to have auto-focus. However, it has a particular spec named "focus_auto" which is bool and set to 1 by default. Can you tell me the meaning of this? Another question is related to camera resolution. I want the best resolution I can have with it. Can you tell me what is it? Thank you and have a nice afternoon.
    • Replysaulius
      Hi Joao, this feature is derived from similar camera which has auto-focus enabled hardware. It does not alter normal camera functionality. Camera has maximal resolution of 1920x1080 pixels and 30 fps max.
  2. Replystephan
    hi i purchased the AR0330 but try to work with it on OS X. for UVC cameras i have use this code so far: http://phoboslab.org/log/2009/07/uvc-camera-control-for-mac-os-x but i am only getting exposure control over the AR0330. is the a OS X equivalent to v4l2-ctl? thanks
    • Replysaulius
      Hi, have not tried advanced settings on OSX. Maybe there is newer version of UVCCameraControl library?
  3. Replypauledd
    Hi. do you have an explanation of this:? Logitech C920 brightness (int) : min=0 max=255 step=1 default=-8193 value=128 The range is from 0 to 255 but the default is completely out of the range with -8193? How can this be?
    • Replysaulius
      Hi, I guess this indicates auto mode (which is set by default).
      • Replysr
        Hi , Does Logitech C920 supports simultaneous multiple video streams ? if it supports we can use YUYV for preview and MJPEG/H264 compressed stream for streaming ? Please help me out
        • Replysaulius
          I think C920 does not support simultaneous streams, at least I don't know how to use this feature. -- BR, Saulius
  4. ReplyWolfie
    This may be stupid, but will the camera let me shoot single shots & record them into my PC; and at what maximal resolution? This must have been asked many times, even a standard reply gratefully accepted. I am an old geezer constantly mislaying documents, and want something really trivial to operate. And robust too.
    • Replysaulius
      Dear Wolfie, maximal Kurokesu C1 camera resolution is 1920x1080.
  5. ReplyEthan
    Hi, I used C922 webcam and try to use this command, v4l2-ctl --set-ctrl=exposure_auto=1 v4l2-ctl --set-ctrl=exposure_absolute=10 It is sometime work fine for me, but sometimes, there was an error when I try to set the exposure_absolute For example: :~$v4l2-ctl --set-ctrl=exposure_auto=1 ======>ok :~$v4l2-ctl --set-ctrl=exposure_absolute=10 ====>ok :~$v4l2-ctl --set-ctrl=exposure_absolute=7 =====>failure VIDIOC_S_EXT_CTRLS: failed: Input/output error exposure_absolute: Input/output error :~$v4l2-ctl --set-ctrl=exposure_absolute=7 =====>failure VIDIOC_S_EXT_CTRLS: failed: Input/output error exposure_absolute: Input/output error :~$v4l2-ctl --set-ctrl=exposure_absolute=7 =====>ok I don't know why.
    • Replysaulius
      Hi, I don't have working Linux distribution at the moment. Could you please try v4l2 commands --list-ctrls and --list-ctrls-menus and post output here?
    • Replydan
      Ethan, unfortunately the C922 is not supported as good as the C920. On Linux they are two completely different animals. This post on stackexchange explains why: https://raspberrypi.stackexchange.com/questions/63798/get-h264-from-webcam-logitech-c922/91885#91885 It might give you a hint why your command is not working.
  6. Replyignik
    Logitech BRIO (usb-0000:00:1a.0-1.1): /dev/video0 brightness (int) : min=0 max=255 step=1 default=128 value=128 contrast (int) : min=0 max=255 step=1 default=128 value=128 saturation (int) : min=0 max=255 step=1 default=128 value=128 white_balance_temperature_auto (bool) : default=1 value=1 gain (int) : min=0 max=255 step=1 default=0 value=0 power_line_frequency (menu) : min=0 max=2 default=2 value=2 white_balance_temperature (int) : min=2000 max=7500 step=10 default=4000 value=2770 flags=inactive sharpness (int) : min=0 max=255 step=1 default=128 value=128 backlight_compensation (int) : min=0 max=1 step=1 default=1 value=1 exposure_auto (menu) : min=0 max=3 default=3 value=3 exposure_absolute (int) : min=3 max=2047 step=1 default=250 value=625 flags=inactive exposure_auto_priority (bool) : default=0 value=1 pan_absolute (int) : min=-36000 max=36000 step=3600 default=0 value=0 tilt_absolute (int) : min=-36000 max=36000 step=3600 default=0 value=0 focus_absolute (int) : min=0 max=255 step=5 default=0 value=20 flags=inactive focus_auto (bool) : default=1 value=1 zoom_absolute (int) : min=100 max=500 step=1 default=100 value=100 led1_mode (menu) : min=0 max=3 default=0 value=3 led1_frequency (int) : min=0 max=255 step=1 default=0 value=0
    • Replysaulius
      Thank you! And apologize for wordpress comment formatter. Included your provided output to blog post.
  7. Replymulti.flexi
    Hi, is it possible to use BRIO at full resolution on Linux? What does v4l2-ctl --list-formats-ext or ffmpeg -f v4l2 -list_formats all -i /dev/video0 output please? I am considering BRIO for one of my projects but I read it is not yet supported well. Thanks.
    • Replysaulius
      Hi, will check later today and let you know results.
    • Replysaulius
      Oops. Don't have any Brio's left to test. Should have new ones in a week or two.
    • Replydan
      first question about v4l2-ctl --list-formats-ext https://pastebin.com/0bpkG2Dq second question about https://pastebin.com/9LAkJ24A
  8. ReplySamogitian
    I would also like to know if it's possible to record 4K with Logitech Brio. I'm on Ubuntu with kernel 4.14, currently can only do 1080p with VLC.
    • Replysaulius
      Hi, don't have Brio at the moment. Will test in a week or two.
  9. ReplySamogitian
    So I got the Brio and managed to record 4K@30fps on Ubuntu. Problem is, compared to all the demo videos on youtube my video looks very grainy, sort of like lots of white noise. I tried 1080p, but result is the same. I used mjpeg for 4K and yuyv422 (raw) for 1080p . Any ideas what could be the issue?
    • Replysaulius
      Hi, it would help a lot if you could share short video clip. For now one guess - maybe there is not enough light or camera is too hot?
    • ReplyZackF
      Hi, Sam. I'm having issues launching/capturing video stream from my BRIO camera on Ubunto using gstreamer (see command below). I also tried changing "format=" to YUYV and MJPG with no success. How were you able to capture video? gst-launch-1.0 v4l2src device=/dev/video1 ! "video/x-raw, width=640, height=480, format=(string)NV12" ! videoconvert ! xvimagesink
  10. ReplyjXs
    hellO, any news about the brio on ubuntu? Still grainyness problems? I'm thinking about purchasing this cam... Also I'd be curious about v4l2-ctl --list-formats-ext THNX
    • Replysaulius
      Hi, not sure about what grainyness you are talking of. But please check v4l2 formats-ext: https://gist.github.com/Lukse/27374af2153db369369a6e17450089bc and ctrls https://gist.github.com/Lukse/6ece58d85bcc4d511c824f197238e15d
  11. Replyericb
    Hello, Thanks a lot for sharing all the valuable information you posted there. If this can help, I'll test all the command lines you proposed, and provide you feedback if something interesting pops up. FYI, I'm using several models for testing purpose (C920, C922, + LifeCam C3000)***, and I was wondering whether an universal way (for portability purpose) exists to check all webcam parameters. Do you stiil sell modified C920 or C922 ? I'm seriously thinking to buy one, but maybe I'm late ... ***(for further information, see https://framagit.org/ericb/miniDart)
    • Replysaulius
      Hi Eric, glad to see your comments! Sure, for cameras feel free to check kurokesu e-store: https://www.kurokesu.com/shop/cameras
      • Replyericb
        Thanks a lot, I'll have a look asap (next week probably), and I'll create a project dedicated to Logitech webcams under Linux on github. It should be more easy to exchange information this way. Just in case you are interested, yet around Logitech Brio case, I proposed some changes in OpenCV (source code is 3.4.0), to use the hardware zoom (name "Zoom, Absolute") with the brio. It works perfectly and I got a 1.0 to 5.0 zoom with the Brio 4K, and a 1.0 to 2.0 with both C920 and C922. (kernel : 4.15.0-24 and above) For further information, please have a look at opencv issue #12498. Please notice it works on Windows, but maybe I didn't include everything. I'm unsure, because I'm cross-compiling the Windows version from Linux ;-) (direct link is : https://github.com/opencv/opencv/issues/12498 ) Thanks again for your great great work !
        • Replysaulius
          That is awesome! Thank you for submitting these changes. I have dome some interesting changes to dshow (Windows camera capture code) source is really outdated and causes lot of issues with some cameras.
  12. Drop Observation Camera – Kyle's Make Blog
    […] a number of computer vision projects. It has a CS mount to support different lenses. It is highly configurable in Linux using v4l2. It’s compact and quite inexpensive (around […]
  13. ReplyNikos
    Hi. Can I use the Logitech Brio for robotics applications and control/access it from Linux?
    • Replysaulius
      Hi Nikos, sure. Just it will probably be limited to 1080p. It is problematic to use 4K video under Linux. And for robotics I would recommend using C1 family camera over Brio (better low light performance, possibility to use cables with lock screws, smaller, ...) -- BR, Saulius
  14. Replygivip
    Hi, I connected C1 camera to Ubuntu 16.04 LTS (on Parallels VM, running on macOS) and can't see h264 device. Here is log: givip@ubuntu:~$ v4l2-ctl --list-devices FaceTime HD Camera: FaceTime HD (usb-0000:00:1d.6-1): /dev/video0 KurokesuC1_SN000830 #2: Kurokes (usb-0000:00:1d.6-2): /dev/video1 givip@ubuntu:~$ v4l2-ctl -d /dev/video1 --info Driver Info (not using libv4l2): Driver name : uvcvideo Card type : KurokesuC1_SN000830 #2: Kurokes Bus info : usb-0000:00:1d.6-2 Driver version: 4.15.18 Capabilities : 0x84200001 Video Capture Streaming Extended Pix Format Device Capabilities Device Caps : 0x04200001 Video Capture Streaming Extended Pix Format And givip@ubuntu:~$ v4l2-ctl -d /dev/video1 --list-ctrls Doesn't return anything. What I do wrong?
    • Replysaulius
      That's interesting and weird. I guess this is OSX parallels virtualization issues. For example Virtualbox running Linux on Windows host behaves as expected.

Leave a reply

Your email address will not be published.