[2022.8.15]v4l2-ctl基本使用方法

article/2025/9/29 17:12:08

v4l2-ctl使用帮助可以参考:https://www.mankier.com/1/v4l2-ctl

1 v4l2-ctl --list-devices

列出所有设备

USB 2.0 Camera: USB Camera (usb-0000:00:14.0-9):/dev/video0/dev/video1

一个USB camera对应两个设备:一个是图像/视频采集,一个是metadata采集。

2 v4l2-ctl --list-formats-ext --device path/to/video_device

列出指定设备的预览支持格式
v4l2-ctl --list-formats-ext --device /dev/video0

ioctl: VIDIOC_ENUM_FMTType: Video Capture[0]: 'MJPG' (Motion-JPEG, compressed)Size: Discrete 2592x1944Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 2560x1440Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Size: Discrete 2048x1536Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1920x1080Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1600x1200Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x960Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x720Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1024x768Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 800x600Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 640x480Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 320x240Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 2592x1944Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)[1]: 'YUYV' (YUYV 4:2:2)Size: Discrete 2592x1944Interval: Discrete 0.200s (5.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 2048x1536Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1920x1080Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1600x1200Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x960Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x720Interval: Discrete 0.100s (10.000 fps)Size: Discrete 1024x768Interval: Discrete 0.100s (10.000 fps)Size: Discrete 800x600Interval: Discrete 0.050s (20.000 fps)Size: Discrete 640x480Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 320x240Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 2592x1944Interval: Discrete 0.200s (5.000 fps)Interval: Discrete 0.200s (5.000 fps)

v4l2-ctl --list-formats-ext --device /dev/video1

ioctl: VIDIOC_ENUM_FMTType: Video Capture

3 v4l2-ctl --all --device path/to/video_device

获取指定设备的所有信息
v4l2-ctl --all --device /dev/video0

Driver Info:Driver name      : uvcvideoCard type        : USB 2.0 Camera: USB CameraBus info         : usb-0000:00:14.0-9Driver version   : 5.11.22Capabilities     : 0x84a00001Video CaptureMetadata CaptureStreamingExtended Pix FormatDevice CapabilitiesDevice Caps      : 0x04200001Video CaptureStreamingExtended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:Width/Height      : 1920/1080Pixel Format      : 'MJPG' (Motion-JPEG)Field             : NoneBytes per Line    : 0Size Image        : 4147789Colorspace        : DefaultTransfer Function : Default (maps to Rec. 709)YCbCr/HSV Encoding: Default (maps to ITU-R 601)Quantization      : Default (maps to Full Range)Flags             :
Crop Capability Video Capture:Bounds      : Left 0, Top 0, Width 1920, Height 1080Default     : Left 0, Top 0, Width 1920, Height 1080Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Streaming Parameters Video Capture:Capabilities     : timeperframeFrames per second: 30.000 (30/1)Read buffers     : 0brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0contrast 0x00980901 (int)    : min=0 max=64 step=1 default=32 value=32saturation 0x00980902 (int)    : min=0 max=128 step=1 default=70 value=70hue 0x00980903 (int)    : min=-40 max=40 step=1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1gamma 0x00980910 (int)    : min=72 max=500 step=1 default=100 value=100gain 0x00980913 (int)    : min=0 max=100 step=1 default=0 value=0power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=10: Disabled1: 50 Hz2: 60 Hzwhite_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactivesharpness 0x0098091b (int)    : min=0 max=6 step=1 default=3 value=3backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=31: Manual Mode3: Aperture Priority Modeexposure_absolute 0x009a0902 (int)    : min=1 max=5000 step=1 default=157 value=157 flags=inactive

v4l2-ctl --all --device /dev/video1

Driver Info:Driver name      : uvcvideoCard type        : USB 2.0 Camera: USB CameraBus info         : usb-0000:00:14.0-9Driver version   : 5.11.22Capabilities     : 0x84a00001Video CaptureMetadata CaptureStreamingExtended Pix FormatDevice CapabilitiesDevice Caps      : 0x04a00000Metadata CaptureStreamingExtended Pix Format
Priority: 2
Format Metadata Capture:Sample Format   : 'UVCH' (UVC Payload Header Metadata)Buffer Size     : 1024

4 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

从特定设备以特定分辨率抓图
v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=MJPG --stream-mmap --stream-to=./output_1920.jpg --stream-count=1
v4l2-ctl --device /dev/video0 --set-fmt-video=width=2560,height=1440,pixelformat=MJPG --stream-mmap --stream-to=./output_2560.jpg --stream-count=1
v4l2-ctl --device /dev/video0 --set-fmt-video=width=2592,height=1944,pixelformat=MJPG --stream-mmap --stream-to=./output_2592.jpg --stream-count=1
FastStoneImageViewer对比看图,1920x1080先scale到2560*1080。
v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=YUYV --stream-mmap --stream-to=./output_1920.yuyv --stream-count=1
...

5 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

从特定设备以特定分辨率抓流
v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=MJPG --stream-mmap --stream-to=./output --stream-count=100
支持264的可以编码为h264看
v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=H264 --stream-mmap --stream-to=./output --stream-count=100
v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=MJPG --stream-mmap --stream-to=./output.mjpg --stream-count=300
找到了可以播放mjpg格式的软件:完美解码的PotPlayer

注意:output.mjpg是输出的文件,默认用PotPlayer软件打开
v4l2-ctl --device /dev/video0 --set-fmt-video=width=2560,height=1440,pixelformat=MJPG --stream-mmap --stream-to=./output_2560.mjpg --stream-count=30
v4l2-ctl --device /dev/video0 --set-fmt-video=width=2592,height=1944,pixelformat=MJPG --stream-mmap --stream-to=./output_2592.mjpg --stream-count=300

6 v4l2-ctl --list-ctrls --device /path/to/video_device

列出设备控制值
v4l2-ctl --list-ctrls --device /dev/video0

                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0contrast 0x00980901 (int)    : min=0 max=64 step=1 default=32 value=32saturation 0x00980902 (int)    : min=0 max=128 step=1 default=70 value=70hue 0x00980903 (int)    : min=-40 max=40 step=1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1gamma 0x00980910 (int)    : min=72 max=500 step=1 default=100 value=100gain 0x00980913 (int)    : min=0 max=100 step=1 default=0 value=0power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactivesharpness 0x0098091b (int)    : min=0 max=6 step=1 default=3 value=3backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3exposure_absolute 0x009a0902 (int)    : min=1 max=5000 step=1 default=157 value=157 flags=inactive

7 v4l2-ctl --stream-mmap --stream-to-host <hostname>

Stream video from /dev/video0 and stream it over the network

8 v4l2-ctl --stream-dmabuf --export-device /dev/video2

Stream video from /dev/video0 using DMABUFs exported from /dev/video2

9 v4l2-ctl --stream-mmap --stream-out-mmap

Stream video from a memory-to-memory device

10 v4l2-ctl -d1 --stream-mmap --out-device /dev/video2 --stream-out-dmabuf

Stream video from a capture video device (/dev/video1) to an output video device (/dev/video2)


http://chatgpt.dhexx.cn/article/RpHy6SWA.shtml

相关文章

V4L2应用层分析

V4L2应用层分析 一、总述二、例子 一、总述 V4L2&#xff0c;即Video for Linux 2&#xff0c;是第二代为Linux打造的音频、视频驱动。相比第一代V4L&#xff0c;V4L2支持更多的设备&#xff0c;同时更加稳定。现今的视频设备&#xff0c;如USB摄像头&#xff0c;基本都支持V4…

v4l2数据结构分析

v4l2数据结构分析 文章目录 v4l2数据结构分析Video4Linux2设备v4l2_device媒体设备media_deviceVideo4Linux2子设备v4l2_subdevVideo4Linux2子设备的操作集v4l2_subdev_opsVideo4Linux2子设备的内部操作集v4l2_subdev_internal_opsVideo4Linux2控制处理器v4l2_ctrl_handlerVide…

摄像头V4L2编程应用开发

1.V4L2简介 Video for Linux two(Video4Linux2)简称V4L2&#xff0c;是V4L的改进版。V4L2是linux系统操作系统下一套用于采集图片、视频、和音视频数据的通用API接口&#xff0c;配合适当的视频采集设备和相应的驱动程序&#xff0c;可以实现图片、视频、音频等的采集。 在linu…

V4L2框架

前言 在分析v4l2之前最好具有的知识&#xff1a; 1.字符设备,因为v4l2是被枚举为字符设备。 2.内存分配和映射,比如相关数据结构的分配和buffer。 3.DMA&#xff0c;因为v4l2的数据传输用到了DMA。 4.I2C&#xff0c;因为很多传感器都是用的i2c接口。 5.文件系统的基本操作&am…

V4L2系列 之 V4L2驱动框架

目录 前言一、V4L2驱动框架概览1、应用层 -》中间层-》驱动层2、主要代码文件(Linux 4.19版本内核) 二、怎么写V4L2驱动1、如何写一个设备的驱动&#xff1f;2、Video设备主要结构体3、怎么写V4L2驱动 三、V4L2的调试工具1、v4l2-ctl2、dev_debug3、v4l2-compliance 前言 本篇文…

V4L2框架概述

原文链接 本文开启 linux 内核 V4L2 框架部分的学习之旅&#xff0c;本文仅先对 V4L2 的框架做一个综述性的概括介绍&#xff0c;然后接下来的文章中会对 V4L2 框架的各个子模块进行一个全面的介绍&#xff0c;包括每一部分的实现原理&#xff0c;如何使用&#xff0c;用在什么…

V4l2框架分析

Table of Contents 1.V4L2框架概述 1.1 v4l2设备应用层流程 1.2 内核V4L2模块 1.2.1 video_device 1.2.2 v4l2_subdev 1.2.3 videobuf2 2. video_device结构体 2.1 图像处理模块 2.2 video_device处理流程 2.2.1 video_device 结构体成员介绍: 3. video_buf2 3.1 …

V4L2

V4L2(video 4 linux 2) V4L2有一段历史了。大约在1998的秋天&#xff0c;它的光芒第一次出现在Bill Dirks 的眼中。经过长足的发展&#xff0c;它于2002年11 月&#xff0c;发布2.5.46 时&#xff0c;融入了内核主干之中。然而直到今天&#xff0c;仍有一部分内核驱不支持新的A…

V4L2简介

http://work-blog.readthedocs.org/en/latest/v4l2%20intro.html 第一章 V4L2简介 1.1、什么是v4l2 V4L2&#xff08;Video4Linux的缩写&#xff09;是Linux下关于视频采集相关设备的驱动框架&#xff0c;为驱动和应用程序提供了一套统一的接口规范。 V4L2支持的设备十分广泛&…

我们一起学linux之V4L2摄像头应用流程

一、概述 Video for Linuxtwo(Video4Linux2)简称V4L2&#xff0c;是V4L的改进版。V4L2是linux操作系统下用于采集图片、视频和音频数据的API接口&#xff0c;配合适当的视频采集设备和相应的驱动程序&#xff0c;可以实现图片、视频、音频等的采集。在远程会议、可视电话、视频…

深入学习Linux摄像头(一)v4l2应用编程

深入学习Linux摄像头&#xff08;一&#xff09;v4l2应用编程 一、什么是v4l2 二、v4l2 API介绍 2.1 Querying Capabilities 2.2 Application Priority 2.3 Device Inputs and Outputs 2.4 Video Standards 2.5 Camera Control Reference 2.6 Image Format 2.7 Cropping, compo…

V4L2驱动框架详解

1. V4L2框架概述 1.1 v4l2设备应用层流程 1.2 内核V4L2模块 2 2. video_device 2.1图像处理模块 2.2 video注册流程 3. videobuf2 3.1 与video device的关系: 3.2 buffer类型 3.3 vb2_ops回调函数 3.4 mmap 流程 4. Subdev 4.1 概念 4.2 subdev注册流程 5. media fra…

html背景自动适应,css背景图片如何自适应?

css可以使用background-size属性设置背景图片自适应&#xff0c;为背景图片设置background-size:cover;样式即可使背景图片自适应。 css可以使用background-size属性设置背景图片自适应。background-size属性规定背景图像的尺寸。 background-size属性&#xff1a; 语法&#x…

css实现图片自适应容器的几种方式

css实现图片自适应容器 经常有这样一个场景,需要让图片自适应容器的大小。 1、img标签的方式 我们马上就能想到,把width、height 设置为100%啊。来看一哈效果。 <div class=div1><img src="./peiqi.png" alt=""> </div>.div1 {widt…

css 背景图片自适应属性整理

本篇博客主要记录一些使用 css 对背景图片自适应的操作整合 背景图片取消重复 background-image: url(image.jpg); background-repeat:no-repeat;修改前 修改后 背景图片固定&#xff08;不会随着内容滚动而改变位置&#xff09; background-image: url(image.jpg); back…

CSS实现图片自适应布局

CSS实现图片自适应布局 最轻松的写法 <div class"container">// 这里图片尺寸为440X440像素&#xff0c;<img src"./images/medium.jpg" alt"test"> </div><style>.container {width: 600px;height: 600px;border: 1p…

CSS图片自适应框架

CSS图片自适应框架 使用img来设置 <!DOCTYPE html> <html><style>body{margin: 0;padding: 10px;}#a_1{display: block;width: 100px;height: 50px;overflow: hidden;padding: 10px;border: dashed;margin: 10px;}#a_1img{width: 100%;height: 100%;}</s…

css之实现图片自适应

文章目录 一、position实现图片自适应二、padding补偿法三、图片以正方形显示 原图如下&#xff1a; 在开发中&#xff0c;想在固定的高度和宽度中显示不一样的图片时&#xff0c;就会出现压缩&#xff0c;导致图片最后显示不好看&#xff0c;以下提供几种方法进行调整&#xf…

css实现图片自适应缩放的两种方法

想要实现图片根据给定宽高来自适应缩放的时候&#xff0c;会想到什么属性&#xff1f;是object-fit: cover;吗&#xff1f; 来试一试&#xff01;为了展示效果&#xff0c;我特地选了对称的图片。下面两个img元素都有一个div包裹&#xff0c;div设置固定宽高&#xff0c;第一个…