• v4l2-ctl基本使用方法


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

    1 v4l2-ctl --list-devices

    列出所有设备

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

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

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

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

    1. ioctl: VIDIOC_ENUM_FMT
    2. Type: Video Capture
    3. [0]: 'MJPG' (Motion-JPEG, compressed)
    4. Size: Discrete 2592x1944
    5. Interval: Discrete 0.033s (30.000 fps)
    6. Interval: Discrete 0.040s (25.000 fps)
    7. Interval: Discrete 0.050s (20.000 fps)
    8. Interval: Discrete 0.067s (15.000 fps)
    9. Interval: Discrete 0.100s (10.000 fps)
    10. Interval: Discrete 0.200s (5.000 fps)
    11. Interval: Discrete 0.033s (30.000 fps)
    12. Interval: Discrete 0.040s (25.000 fps)
    13. Interval: Discrete 0.050s (20.000 fps)
    14. Interval: Discrete 0.067s (15.000 fps)
    15. Interval: Discrete 0.100s (10.000 fps)
    16. Interval: Discrete 0.200s (5.000 fps)
    17. Size: Discrete 2560x1440
    18. Interval: Discrete 0.033s (30.000 fps)
    19. Interval: Discrete 0.050s (20.000 fps)
    20. Interval: Discrete 0.067s (15.000 fps)
    21. Interval: Discrete 0.100s (10.000 fps)
    22. Size: Discrete 2048x1536
    23. Interval: Discrete 0.033s (30.000 fps)
    24. Interval: Discrete 0.040s (25.000 fps)
    25. Interval: Discrete 0.050s (20.000 fps)
    26. Interval: Discrete 0.067s (15.000 fps)
    27. Interval: Discrete 0.100s (10.000 fps)
    28. Interval: Discrete 0.200s (5.000 fps)
    29. Size: Discrete 1920x1080
    30. Interval: Discrete 0.033s (30.000 fps)
    31. Interval: Discrete 0.040s (25.000 fps)
    32. Interval: Discrete 0.050s (20.000 fps)
    33. Interval: Discrete 0.067s (15.000 fps)
    34. Interval: Discrete 0.100s (10.000 fps)
    35. Interval: Discrete 0.200s (5.000 fps)
    36. Size: Discrete 1600x1200
    37. Interval: Discrete 0.033s (30.000 fps)
    38. Interval: Discrete 0.040s (25.000 fps)
    39. Interval: Discrete 0.050s (20.000 fps)
    40. Interval: Discrete 0.067s (15.000 fps)
    41. Interval: Discrete 0.100s (10.000 fps)
    42. Interval: Discrete 0.200s (5.000 fps)
    43. Size: Discrete 1280x960
    44. Interval: Discrete 0.033s (30.000 fps)
    45. Interval: Discrete 0.040s (25.000 fps)
    46. Interval: Discrete 0.050s (20.000 fps)
    47. Interval: Discrete 0.067s (15.000 fps)
    48. Interval: Discrete 0.100s (10.000 fps)
    49. Interval: Discrete 0.200s (5.000 fps)
    50. Size: Discrete 1280x720
    51. Interval: Discrete 0.033s (30.000 fps)
    52. Interval: Discrete 0.040s (25.000 fps)
    53. Interval: Discrete 0.050s (20.000 fps)
    54. Interval: Discrete 0.067s (15.000 fps)
    55. Interval: Discrete 0.100s (10.000 fps)
    56. Interval: Discrete 0.200s (5.000 fps)
    57. Size: Discrete 1024x768
    58. Interval: Discrete 0.033s (30.000 fps)
    59. Interval: Discrete 0.040s (25.000 fps)
    60. Interval: Discrete 0.050s (20.000 fps)
    61. Interval: Discrete 0.067s (15.000 fps)
    62. Interval: Discrete 0.100s (10.000 fps)
    63. Interval: Discrete 0.200s (5.000 fps)
    64. Size: Discrete 800x600
    65. Interval: Discrete 0.033s (30.000 fps)
    66. Interval: Discrete 0.040s (25.000 fps)
    67. Interval: Discrete 0.050s (20.000 fps)
    68. Interval: Discrete 0.067s (15.000 fps)
    69. Interval: Discrete 0.100s (10.000 fps)
    70. Interval: Discrete 0.200s (5.000 fps)
    71. Size: Discrete 640x480
    72. Interval: Discrete 0.033s (30.000 fps)
    73. Interval: Discrete 0.040s (25.000 fps)
    74. Interval: Discrete 0.050s (20.000 fps)
    75. Interval: Discrete 0.067s (15.000 fps)
    76. Interval: Discrete 0.100s (10.000 fps)
    77. Interval: Discrete 0.200s (5.000 fps)
    78. Size: Discrete 320x240
    79. Interval: Discrete 0.033s (30.000 fps)
    80. Interval: Discrete 0.040s (25.000 fps)
    81. Interval: Discrete 0.050s (20.000 fps)
    82. Interval: Discrete 0.067s (15.000 fps)
    83. Interval: Discrete 0.100s (10.000 fps)
    84. Interval: Discrete 0.200s (5.000 fps)
    85. Size: Discrete 2592x1944
    86. Interval: Discrete 0.033s (30.000 fps)
    87. Interval: Discrete 0.040s (25.000 fps)
    88. Interval: Discrete 0.050s (20.000 fps)
    89. Interval: Discrete 0.067s (15.000 fps)
    90. Interval: Discrete 0.100s (10.000 fps)
    91. Interval: Discrete 0.200s (5.000 fps)
    92. Interval: Discrete 0.033s (30.000 fps)
    93. Interval: Discrete 0.040s (25.000 fps)
    94. Interval: Discrete 0.050s (20.000 fps)
    95. Interval: Discrete 0.067s (15.000 fps)
    96. Interval: Discrete 0.100s (10.000 fps)
    97. Interval: Discrete 0.200s (5.000 fps)
    98. [1]: 'YUYV' (YUYV 4:2:2)
    99. Size: Discrete 2592x1944
    100. Interval: Discrete 0.200s (5.000 fps)
    101. Interval: Discrete 0.200s (5.000 fps)
    102. Size: Discrete 2048x1536
    103. Interval: Discrete 0.200s (5.000 fps)
    104. Size: Discrete 1920x1080
    105. Interval: Discrete 0.200s (5.000 fps)
    106. Size: Discrete 1600x1200
    107. Interval: Discrete 0.200s (5.000 fps)
    108. Size: Discrete 1280x960
    109. Interval: Discrete 0.200s (5.000 fps)
    110. Size: Discrete 1280x720
    111. Interval: Discrete 0.100s (10.000 fps)
    112. Size: Discrete 1024x768
    113. Interval: Discrete 0.100s (10.000 fps)
    114. Size: Discrete 800x600
    115. Interval: Discrete 0.050s (20.000 fps)
    116. Size: Discrete 640x480
    117. Interval: Discrete 0.033s (30.000 fps)
    118. Interval: Discrete 0.040s (25.000 fps)
    119. Interval: Discrete 0.050s (20.000 fps)
    120. Interval: Discrete 0.067s (15.000 fps)
    121. Interval: Discrete 0.100s (10.000 fps)
    122. Interval: Discrete 0.200s (5.000 fps)
    123. Size: Discrete 320x240
    124. Interval: Discrete 0.033s (30.000 fps)
    125. Interval: Discrete 0.040s (25.000 fps)
    126. Interval: Discrete 0.050s (20.000 fps)
    127. Interval: Discrete 0.067s (15.000 fps)
    128. Interval: Discrete 0.100s (10.000 fps)
    129. Interval: Discrete 0.200s (5.000 fps)
    130. Size: Discrete 2592x1944
    131. Interval: Discrete 0.200s (5.000 fps)
    132. Interval: Discrete 0.200s (5.000 fps)

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

    1. ioctl: VIDIOC_ENUM_FMT
    2. Type: Video Capture

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

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

    1. Driver Info:
    2. Driver name : uvcvideo
    3. Card type : USB 2.0 Camera: USB Camera
    4. Bus info : usb-0000:00:14.0-9
    5. Driver version : 5.11.22
    6. Capabilities : 0x84a00001
    7. Video Capture
    8. Metadata Capture
    9. Streaming
    10. Extended Pix Format
    11. Device Capabilities
    12. Device Caps : 0x04200001
    13. Video Capture
    14. Streaming
    15. Extended Pix Format
    16. Priority: 2
    17. Video input : 0 (Camera 1: ok)
    18. Format Video Capture:
    19. Width/Height : 1920/1080
    20. Pixel Format : 'MJPG' (Motion-JPEG)
    21. Field : None
    22. Bytes per Line : 0
    23. Size Image : 4147789
    24. Colorspace : Default
    25. Transfer Function : Default (maps to Rec. 709)
    26. YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    27. Quantization : Default (maps to Full Range)
    28. Flags :
    29. Crop Capability Video Capture:
    30. Bounds : Left 0, Top 0, Width 1920, Height 1080
    31. Default : Left 0, Top 0, Width 1920, Height 1080
    32. Pixel Aspect: 1/1
    33. Selection Video Capture: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
    34. Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
    35. Streaming Parameters Video Capture:
    36. Capabilities : timeperframe
    37. Frames per second: 30.000 (30/1)
    38. Read buffers : 0
    39. brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
    40. contrast 0x00980901 (int) : min=0 max=64 step=1 default=32 value=32
    41. saturation 0x00980902 (int) : min=0 max=128 step=1 default=70 value=70
    42. hue 0x00980903 (int) : min=-40 max=40 step=1 default=0 value=0
    43. white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
    44. gamma 0x00980910 (int) : min=72 max=500 step=1 default=100 value=100
    45. gain 0x00980913 (int) : min=0 max=100 step=1 default=0 value=0
    46. power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
    47. 0: Disabled
    48. 1: 50 Hz
    49. 2: 60 Hz
    50. white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
    51. sharpness 0x0098091b (int) : min=0 max=6 step=1 default=3 value=3
    52. backlight_compensation 0x0098091c (int) : min=0 max=2 step=1 default=1 value=1
    53. exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=3
    54. 1: Manual Mode
    55. 3: Aperture Priority Mode
    56. exposure_absolute 0x009a0902 (int) : min=1 max=5000 step=1 default=157 value=157 flags=inactive

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

    1. Driver Info:
    2. Driver name : uvcvideo
    3. Card type : USB 2.0 Camera: USB Camera
    4. Bus info : usb-0000:00:14.0-9
    5. Driver version : 5.11.22
    6. Capabilities : 0x84a00001
    7. Video Capture
    8. Metadata Capture
    9. Streaming
    10. Extended Pix Format
    11. Device Capabilities
    12. Device Caps : 0x04a00000
    13. Metadata Capture
    14. Streaming
    15. Extended Pix Format
    16. Priority: 2
    17. Format Metadata Capture:
    18. Sample Format : 'UVCH' (UVC Payload Header Metadata)
    19. 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

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

    7 v4l2-ctl --stream-mmap --stream-to-host

    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)

  • 相关阅读:
    2023/9/13 -- C++/QT
    uniapp使用scroll-into-view实现锚点定位和滚动监听功能【楼层效果 / 侧边导航联动效果】
    模板template
    day59【单调栈】503.下一个更大元素Ⅱ 42.接雨水 84.柱状图中最大的矩形
    千寻简Java词典音标版
    SpringBoot SpringBoot 原理篇 1 自动配置 1.2 bean 的加载方式【二】
    【计算机视觉40例】案例34:勾勒五官轮廓
    Python--traceback模块的基本用法(异常处理)
    天空卫士加入工信部重点实验室大数据安全工作组
    Linux生成UUID的算法方式(序列号C/C++代码实现)
  • 原文地址:https://blog.csdn.net/u012906122/article/details/126356698