yavta 是一款测试APP,测试UVC 摄像头的数据采集回传。
yavta -f YUYV -s 1280x720 -t 1/60 -c100 /dev/video0 -F/data/yua
帧率60FPS 不能正常运行,blocked, all frame fail。
yavta -f YUYV -s 1280x720 -t 1/30 -c100 /dev/video0 -F/data/yua
帧率30FPS 能正常运行,但中间也会有一些丢包。
帧率:FPS(每秒钟要多少帧画面); 以及Gop(表示多少秒一个I帧),影响流畅度。
-t 1/60 // 帧率60,一秒钟传输60 帧
分辨率:单位英寸中所包含的像素点数; VGA:Video Graphics Array(视频图像分辨率),影响清晰度。
-s 1280x720 // 分辨率720P
视频大小:分辨率 x 2(每个像素占多少字节) x 8 x 帧率 x 时间(s) /1024/1024
YUV422 格式帧大小:分辨率 x 2 Byte
对于YUV422 格式的 1080P 视频而言,一帧图像是 1920x1080x2x8/1024/1024 = 31.64Mbit,1秒钟30帧图像的话,则有949.2Mb/s。
root@qrb5165-rb5:/# strace yavta -f YUYV -s 1280x720 -t 1/60 -c100 /dev/video0
// 解析参数
execve("/usr/bin/yavta", ["yavta", "-f", "YUYV", "-s", "1280x720", "-t", "1/60", "-c100", "/dev/video0"], 0x7fc5203a80 /* 16 vars */) = 0
// 打开设备节点
openat(AT_FDCWD, "/dev/video0", O_RDWR) = 3
// 回显显示
write(1, "Device /dev/video0 opened.\n", 27Device /dev/video0 opened.) = 27
// 设备节点的ioctl
ioctl(3, VIDIOC_QUERYCAP, {driver="uvcvideo", card="KS2A418: KS2A418", bus_info="usb-xhci-hcd.0.auto-1.3", version=4.19.125, ...) = 0
// 回显显示
write(1, "Device `KS2A418: KS2A418' on `us"..., 117Device `KS2A418: KS2A418' on `usb-xhci-hcd.0.auto-1.3' (driver 'uvcvideo') supports video, capture, without mplanes.) = 117
// ioctl 设置参数
ioctl(3, VIDIOC_G_PARM, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, parm.capture={capability=V4L2_CAP_TIMEPERFRAME, capturemode=0, timeperframe=1/60, extendedmode=0, readbuffers=0}}) = 0
write(1, "Current frame rate: 1/60\n", 25Current frame rate: 1/60) = 25
write(1, "Setting frame rate to: 1/60\n", 28Setting frame rate to: 1/60) = 28
...
这些ioctl 对应驱动的接口为:
// \drivers\media\usb\uvc\uvc_v4l2.c
const struct v4l2_ioctl_ops uvc_ioctl_ops = {
.vidioc_querycap = uvc_ioctl_querycap,
...
.vidioc_reqbufs = uvc_ioctl_reqbufs,
.vidioc_querybuf = uvc_ioctl_querybuf,
.vidioc_qbuf = uvc_ioctl_qbuf,
.vidioc_expbuf = uvc_ioctl_expbuf,
.vidioc_dqbuf = uvc_ioctl_dqbuf,
.vidioc_create_bufs = uvc_ioctl_create_bufs,
.vidioc_streamon = uvc_ioctl_streamon,
.vidioc_streamoff = uvc_ioctl_streamoff,
...
};