• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

v4l2-ctl Command Examples in Linux

by Deepika

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

Summary

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.

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to configure an DHCP server
  2. loginctl: command not found
  3. zip Command Examples in Linux
  4. swapon and swapoff Command Examples in Linux
  5. xz: command not found
  6. setxkbmap Command Examples in Linux
  7. nmon: command not found
  8. mktemp Command Examples in Linux
  9. fprintd-delete: command not found
  10. mkfs.vfat Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright