Get v4l2 video devices maximum resolution
linux, resolution, v4l2, video-capture
Solution
use the `VIDIOC_ENUM_FRAMESIZES` ioctl:
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_fmtdesc fmt;
struct v4l2_frmsizeenum frmsize;
struct v4l2_frmivalenum frmival;
fmt.index = 0;
fmt.type = type;
while (ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
frmsize.pixel_format = fmt.pixelformat;
frmsize.index = 0;
while (ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) >= 0) {
if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
printf("%dx%d\n",
frmsize.discrete.width,
frmsize.discrete.height);
} else if (frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
printf("%dx%d\n",
frmsize.stepwise.max_width,
frmsize.stepwise.max_height);
}
frmsize.index++;
}
fmt.index++;
}
afaik, `VIDIOC_ENUM_FRAMESIZES` was introduced in linux-2.6.29
Problem
how can I just detect the maximum resolution a connected video device is able to provide? I do not want to capture anything, just retrieve this information from v4l2. Thanks!