About a month ago I gave a few examples on the topic of controlling your Video4Linux compatible webcam device on Ubuntu Linux operating system. Here's the link if you are interested:
Today we will approach that topic from a different angle. We will use CLI to control our webcam device. Who would want to control visual device like webcam from CLI you might ask? I'm doing it CLI way, because I want to tweak my webcam using my Linux operating system startup scripts. That's something I can't do by using GUI.
Second reason for using CLI for webcam control could be that you feel better typing commands on your terminal instead of clicking around with your mouse. Or maybe you don't have mouse or GUI available? Anyways, lets get started...
For controlling webcam from Linux terminal we will use nifty little program "V4l2-ctl". Now I will give you short instructions how to install it on Fedora and Ubuntu.
Installing "V4l2-ctl" on Fedora
Here's how to install "V4l2-ctl" on Fedora Linux operating system:
su -c 'yum install v4l-utils'
Installing "V4l2-ctl" on Ubuntu
Here's how to install "V4l2-ctl" on Ubuntu Linux operating system:
sudo apt-get install v4l-utils
After installing "V4l2-ctl" you can use following command to get basic info about your Video4Linux device:
Next thing to do is to "probe" you webcam capabilities and controls:
We will use the output of the
v4l2-ctl--list ctrls command to see what can we control. Output of this command could be something like this:
brightness (int) : min=0 max=255 step=1 default=128 value=128 contrast (int) : min=0 max=255 step=1 default=128 value=128 gamma (int) : min=1 max=6 step=1 default=4 value=4 auto_gain (bool) : default=1 value=1 light_frequency_filter (menu) : min=0 max=2 default=0 value=0 sharpness (int) : min=0 max=3 step=1 default=2 value=2
Now when we know what can we control, we can for example increase
brightness to 200 out of maximum 255 and turn the
auto_gain off. Here's how:
v4l2-ctl --set-ctrl brightness=200 v4l2-ctl --set-ctrl auto_gain=0
Now you can check are your settings applied by issuing
v4l2-ctl --list-ctrls command again. Your next step could be putting your settings inside BASH and using this script to apply your webcam settings at boot. If you are interested in something like that and you run Debian based operating system like Ubuntu you can find more info in the "Step 2" of my following article:
My friends, that's it for this little CLI webcam guide. Live long and prosper!