Skip to content

Instantly share code, notes, and snippets.

@sepastian
Last active June 29, 2023 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sepastian/da2b69b79ee8db29e511359e006648a0 to your computer and use it in GitHub Desktop.
Save sepastian/da2b69b79ee8db29e511359e006648a0 to your computer and use it in GitHub Desktop.
V4L2 set camera zoom level

Environment

$ uname -a
Linux x220 6.3.0-1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.3.7-1 (2023-06-12) x86_64 GNU/Linux

List Cameras

$ v4l2-ctl --list-devices                           
Integrated Camera: Integrated C (usb-0000:00:1a.0-1.6):
	/dev/video2
	/dev/video3
	/dev/media1

Razer Kiyo (usb-0000:0e:00.0-2.4):
	/dev/video0
	/dev/video1
	/dev/media0

Query Camera Settings

My camera is a Razer Kiyo, which supports setting the zoom level. Other cameras may not support this.

List all settings and look for ones containing zoom.

$ v4l2-ctl -d /dev/video0 -l | grep zoom | tr -s ' '
 zoom_absolute 0x009a090d (int) : min=100 max=140 step=10 default=100 value=100

Set Zoom Level

Finally, set the zoom level.

$ v4l2-ctl -d /dev/video0 -c zoom_absolute=115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment