Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Tweak Webcam Settings In The CLI

I just set up a new webcam after having lost my old one somewhere, and the colours were dramatically different. It felt like "too colourful" and needed adjusting, but in a way that would work for all applications that used the webcam, rather than being a setting in a specific application like OBS or cheese.

Luckily, there is a way to tweak your camera settings through the CLI, to adjust the picture and this tutorial will show you how.


sudo apt update \
  && sudo apt install v4l-utils

List Possible Controls

Different webcams will have different controls that you can manipulate. Run the following command to see what controls you have, and what values you can set.

v4l2-ctl --list-ctrls

This should output something similar to:

User Controls

                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast 0x00980901 (int)    : min=0 max=95 step=1 default=2 value=0
                     saturation 0x00980902 (int)    : min=0 max=100 step=1 default=86 value=0
                            hue 0x00980903 (int)    : min=-2000 max=2000 step=100 default=0 value=0
        white_balance_automatic 0x0098090c (bool)   : default=1 value=0
                          gamma 0x00980910 (int)    : min=100 max=300 step=1 default=100 value=100
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1 (50 Hz)
      white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4600 value=4400
                      sharpness 0x0098091b (int)    : min=1 max=7 step=1 default=2 value=2
         backlight_compensation 0x0098091c (int)    : min=0 max=3 step=1 default=0 value=0

Camera Controls

                  auto_exposure 0x009a0901 (menu)   : min=0 max=3 default=3 value=3 (Aperture Priority Mode)
         exposure_time_absolute 0x009a0902 (int)    : min=78 max=10000 step=1 default=312 value=312 flags=inactive
                 focus_absolute 0x009a090a (int)    : min=0 max=15 step=1 default=0 value=0 flags=inactive
     focus_automatic_continuous 0x009a090c (bool)   : default=1 value=1

Adjust Settings

Now that you can see what controls you have, use the -c or --set-ctrl option to set values. Below are the commands I would use to set my new webcam up how I like:

v4l2-ctl --set-ctrl brightness=0
v4l2-ctl --set-ctrl contrast=2
v4l2-ctl --set-ctrl saturation=86
v4l2-ctl --set-ctrl gamma=100
v4l2-ctl --set-ctrl hue=0
v4l2-ctl --set-ctrl backlight_compensation=0
v4l2-ctl --set-ctrl white_balance_automatic=0
v4l2-ctl --set-ctrl white_balance_temperature=4000
Last updated: 3rd March 2024
First published: 28th February 2024