summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2018-04-07 12:24:19 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2018-04-07 12:24:19 +0200
commitb3bd9972e0633451eecff834297d3cc139d69b4b (patch)
tree0e0515878dc28f8b8a8840cf55d7ff8e99fa8131 /modules
parent4c7f08692078199914aafabb0ef19c2c9b5ff1be (diff)
v4l2: print actual framerate
Diffstat (limited to 'modules')
-rw-r--r--modules/v4l2/v4l2.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/v4l2/v4l2.c b/modules/v4l2/v4l2.c
index 983ad53..20ad762 100644
--- a/modules/v4l2/v4l2.c
+++ b/modules/v4l2/v4l2.c
@@ -106,6 +106,28 @@ static void print_video_input(const struct vidsrc_st *st)
}
+static void print_framerate(const struct vidsrc_st *st)
+{
+ struct v4l2_streamparm streamparm;
+ struct v4l2_fract tpf;
+ double fps;
+
+ memset(&streamparm, 0, sizeof(streamparm));
+
+ streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (v4l2_ioctl(st->fd, VIDIOC_G_PARM, &streamparm) != 0) {
+ warning("v4l2: VIDIOC_G_PARM error (%m)\n", errno);
+ return;
+ }
+
+ tpf = streamparm.parm.capture.timeperframe;
+ fps = (double)tpf.denominator / (double)tpf.numerator;
+
+ info("v4l2: current framerate is %.2f fps\n", fps);
+}
+
+
static int xioctl(int fd, unsigned long int request, void *arg)
{
int r;
@@ -470,6 +492,8 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs,
print_video_input(st);
+ print_framerate(st);
+
err = start_capturing(st);
if (err)
goto out;