v4l2-ctl is a command-line tool for controlling video devices on Linux systems. It is a part of the Video4Linux2 (V4L2) framework, which is a kernel interface for video devices such as webcams, TV tuner cards, and digital cameras. The V4L2 framework provides a standardized way for applications to interact with video devices and supports a wide range of features and controls.
v4l2-ctl allows users to query and set various parameters of video devices, such as resolution, frame rate, format, and image controls. It can also be used to retrieve information about a device, such as the supported controls and capabilities. The tool supports a wide range of video devices, including USB cameras, network cameras, and TV tuner cards.
One of the most useful features of v4l2-ctl is its ability to display the current settings and capabilities of a video device. Users can run v4l2-ctl –list-formats-ext to display the supported pixel formats, resolutions, and frame rates of the device. They can also run v4l2-ctl –list-ctrls to display the available controls and their current values.
v4l2-ctl Command Examples
1. List all video devices:
# v4l2-ctl --list-devices
2. List supported video formats and resolutions of default video device `/dev/video0`:
# v4l2-ctl --list-formats-ext
3. List supported video formats and resolutions of a specific video device:
# v4l2-ctl --list-formats-ext --device path/to/video_device
4. Get all details of a video device:
# v4l2-ctl --all --device path/to/video_device
5. Capture a JPEG photo with a specific resolution from video device:
# v4l2-ctl --device path/to/video_device --set-fmt-video=width=width,height=height,pixelformat=MJPG --stream-mmap --stream-to=path/to/output.jpg --stream-count=1
6. Capture a raw video stream from video device:
# v4l2-ctl --device path/to/video_device --set-fmt-video=width=width,height=height,pixelformat=format --stream-mmap --stream-to=path/to/output --stream-count=number_of_frames_to_capture
7. List all video device’s controls and their values:
# v4l2-ctl --list-ctrls --device /path/to/video_device
In addition to its basic features, v4l2-ctl can also be used in conjunction with other tools and libraries to build more advanced video applications. For example, it can be used with the OpenCV library to capture and process video frames in real time.
Overall, v4l2-ctl is a powerful tool for controlling video devices on Linux systems and can be useful for both casual users and developers working on video-related applications.