I'm trying to use V4L2 api to enumertate supported frame size and frame rate of webcam device. I try to do it with the following code without success. The ioctl function always returns -1.
#include <stdio.h>
#include <fcntl.h>
#include "linux/videodev2.h"
int main(int argc, char **argv) {
int fd = open("/dev/video0", O_RDWR);
struct v4l2_frmivalenum frmsize;
memset(&frmsize, 0, sizeof (struct v4l2_frmsizeenum));
ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS , &frmsize);
printf("%u \n", frmsize.he);
return 0;
}
You should set the in parameter before ioctl VIDIOC_ENUM_FRAMESIZES to get frame sizes :
and ioctl VIDIOC_ENUM_FRAMEINTERVALS to get frame intervals :
Then an implementation that enumerates frame sizes and frame intervals could be :