v4l2-ctl
Control and configure video capture devices
TLDR
List all video devices
List supported video formats and resolutions of default video device /dev/video0
List supported video formats and resolutions of a specific video device
Get all details of a video device
Capture a JPEG photo with a specific resolution from video device
Capture a raw video stream from video device
List all video device's controls and their values
Set the value of a video device control
SYNOPSIS
v4l2-ctl [options] [-d device]
PARAMETERS
-d, --device
Specifies the V4L2 device node to operate on, e.g., /dev/video0. If not specified, /dev/video0 is used by default.
-a, --all
Shows all available information for the selected device, including capabilities, formats, and controls.
-l, --list-ctrls
Lists all V4L2 controls (e.g., brightness, contrast, exposure) available for the device, along with their current values, ranges, and types.
-c, --get-ctrl
Gets the current value of a specific control by its name.
-C, --set-ctrl
Sets the value of a specific control. Multiple controls can be set by separating them with commas (e.g., brightness=128,contrast=64).
-P, --list-formats
Lists all supported video capture formats (pixel formats and resolutions) that the device can provide.
-V, --get-fmt
Shows the current video input format (resolution, pixel format, field, etc.) being used by the device.
-v, --set-fmt
Sets the video input format. Pixel format can be specified by fourcc code (e.g., YUYV) or name (e.g., YUYV).
-S, --set-stream
Starts or stops video streaming from the device. Requires on or off as an argument.
--list-devices
Lists all detected V4L2 devices and their associated device nodes, providing an overview of available hardware.
--info
Displays detailed information about the device's capabilities, driver, and kernel modules.
--help
Shows the command's help message and a summary of available options.
DESCRIPTION
The v4l2-ctl command is a versatile utility from the v4l-utils package, designed to interact with and configure Video4Linux2 (V4L2) compliant devices. These devices typically include webcams, TV tuners, capture cards, and other video input/output hardware. It provides a command-line interface to the V4L2 API, allowing users to query device capabilities, list supported video formats, set resolution and frame rates, adjust image controls (like brightness, contrast, exposure, white balance), manage video inputs/outputs, and perform basic streaming operations. It's an indispensable tool for debugging, scripting, and fine-tuning the behavior of video devices on Linux systems, particularly when graphical interfaces are unavailable or insufficient for specific configurations.
CAVEATS
Some operations, such as changing system-wide device parameters or certain video modes, may require root privileges. Device behavior can vary significantly based on the specific hardware and its V4L2 driver implementation. Not all options or controls are supported by all V4L2 devices. Always consult the device's documentation or experiment cautiously.
COMMON CONTROL TYPES
V4L2 controls are categorized by type, such as integer (e.g., brightness, contrast), boolean (e.g., auto exposure), menu (e.g., power line frequency), bitmask, or string. When setting controls using --set-ctrl, ensure the provided value matches the expected type for that control, which can be determined by first listing controls with --list-ctrls.
STREAMING OPTIONS
While v4l2-ctl can initiate basic streaming using --set-stream, it also supports more advanced streaming options for testing purposes. These include --stream-to
HISTORY
The v4l2-ctl command is part of the v4l-utils project, which provides a collection of tools for the Video4Linux2 API. V4L2 itself is the second generation of the Linux kernel's video device interface, superseding the original Video4Linux (V4L) API. It was developed to offer a more robust and flexible framework for handling video capture, output, and processing devices. v4l2-ctl emerged as the primary command-line interface for testing, debugging, and configuring these devices, reflecting the ongoing evolution of multimedia support in the Linux kernel.
SEE ALSO
ffmpeg(1), motion(1), fswebcam(1), media-ctl(1), uvcdynctrl(1), v4l2-compliance(1)