Forrest logo
back to the v4l2-ctl tool

v4l2-ctl:tldr:2bde2

v4l2-ctl: 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}
try on your machine

This is a command used to configure and capture video frames from a specific video device using the Video4Linux2 (v4l2) control tool.

Here is the breakdown of the command:

  • v4l2-ctl: This is the executable command for the v4l2 control tool, which is used to control and configure video devices.

  • --device ${path-to-video_device}: It specifies the path to the video device from which the video frames will be captured. You need to replace ${path-to-video_device} with the actual path.

  • --set-fmt-video=width=${width},height=${height},pixelformat=${format}: This option sets the desired video format for capturing frames. You need to replace ${width} with the desired width of the frames, ${height} with the desired height, and ${format} with the desired pixel format (e.g., YUYV, MJPEG, etc.).

  • --stream-mmap: This option enables memory mapping as the method for data transfer during video streaming.

  • --stream-to=${path-to-output}: It specifies the path and filename of the output file where the captured video frames will be saved. You need to replace ${path-to-output} with the actual path and filename.

  • --stream-count=${number_of_frames_to_capture}: This option sets the number of frames to capture. You need to replace ${number_of_frames_to_capture} with the desired number of frames.

Overall, this command configures the video device to capture video frames in a specific format and saves them to a file for the specified number of frames.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the v4l2-ctl tool