我有 Raspberry Pi 4 (aarch64 Cortex-A72),安装了操作系统 Ubuntu 22.04 LTS 64 位。我尝试从网络摄像头读取帧。
当我运行此代码时:
if (ioctl(fd, VIDIOC_DQBUF, &buf) < 0) {
std::cout << "V4lNode failed dequeue frame from buffer: " << strerror(errno) << std::endl;
}
我得到输出结果:
V4lNode 无法从缓冲区中出队帧:资源暂时不可用
但设备打开成功:
fd = open(path.c_str(), O_RDWR | O_NONBLOCK, 0);
std::cout << "V4lNode open files discription: " << strerror(errno) << std::endl;
输出结果:
V4lNode打开文件描述:成功
当我在终端运行 v4l2 测试时:
pi@pi:~$ v4l2-compliance
v4l2-compliance 1.22.1, 64 bits, 64-bit time_t
Compliance test for uvcvideo device /dev/video0:
Driver Info:
Driver name : uvcvideo
Card type : Intel F450
Bus info : usb-0000:01:00.0-1.1
Driver version : 5.15.39
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : Intel F450
Serial : 00.00.01
Bus info : usb-0000:01:00.0-1.1
Media version : 5.15.39
Hardware revision: 0x00000100 (256)
Driver version : 5.15.39
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : Intel F450
Function : V4L2 I/O
Flags : default
Pad 0x01000007 : 0: Sink
Link 0x02000010: from remote pad 0x100000a of entity 'Extension 3' (Video Pixel Formatter): Data, Enabled, Immutable
Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(246): missing control class for class 00980000
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
warn: v4l2-test-controls.cpp(757): g_ext_ctrls(0) invalid error_idx 0
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 1 Private Controls: 0
Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
warn: v4l2-test-formats.cpp(1036): Could not set fmt2
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
Total for uvcvideo device /dev/video0: 46, Succeeded: 45, Failed: 1, Warnings: 2
我收到错误:
Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(246): missing control class for class 00980000
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL
还会混淆很多笔记(Not Supported)
。
更新型多巴胺
输出格式:
pi@pi:~$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
输出dmesg
错误:
[ 0.823576] zswap: compressor zstd not available, using default lzo
[ 0.829609] zswap: zpool z3fold not available, using default zbud
[ 102.238315] uvcvideo 1-1.1:1.1: Failed to resubmit video URB (-1).
[ 102.238626] uvcvideo 1-1.1:1.1: Failed to resubmit video URB (-1).
[ 5822.239686] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.249854] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.259913] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.269949] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.280057] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.290139] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.391565] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.401637] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.411679] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.421697] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.431779] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.441885] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.532650] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5822.563375] usb 1-1.1: Failed to query (SET_CUR) UVC control 4 on unit 1: -32 (exp. 4).
[ 5822.622056] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5823.168241] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
[ 5823.270367] usb 1-1.1: Failed to query (SET_CUR) UVC control 10 on unit 2: -32 (exp. 2).
我尝试过这个解决方案https://stackoverflow.com/questions/46253564/recording-usb-cam-on-raspberry-pi-with-ffmpeg-usb-troubleshooting- 不起作用
您有什么想法吗?