summaryrefslogtreecommitdiff
path: root/libavdevice/v4l2.c
diff options
context:
space:
mode:
authorJosé Miguel Gonçalves <jose.goncalves@inov.pt>2010-09-23 09:16:05 +0000
committerLuca Abeni <lucabe72@email.it>2010-09-23 09:16:05 +0000
commit70f77361d8c339d516e3c4d1c4ab2bf9096d7cc6 (patch)
treec34320438dbc0c8de1bd48d47c595d849f0b8dba /libavdevice/v4l2.c
parent6ac6e3d1237475427ecc448d6cb2d67617687997 (diff)
Allow to set the frame rate in v4l2 devices
Patch by José Miguel Gonçalves (jose DOT goncalves AT inov DOT pt) Originally committed as revision 25159 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r--libavdevice/v4l2.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 6b85cf0594..035e41633d 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -489,6 +489,33 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
}
}
+ if (ap->time_base.num && ap->time_base.den) {
+ struct v4l2_streamparm streamparm = { 0 };
+ struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
+
+ av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n",
+ ap->time_base.num, ap->time_base.den);
+ streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ tpf->numerator = ap->time_base.num;
+ tpf->denominator = ap->time_base.den;
+ if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) {
+ av_log(s1, AV_LOG_ERROR,
+ "ioctl set time per frame(%d/%d) failed\n",
+ ap->time_base.num, ap->time_base.den);
+ return AVERROR(EIO);
+ }
+
+ if (ap->time_base.den != tpf->denominator ||
+ ap->time_base.num != tpf->numerator) {
+ av_log(s1, AV_LOG_INFO,
+ "The driver changed the time per frame from %d/%d to %d/%d\n",
+ ap->time_base.num, ap->time_base.den,
+ tpf->numerator, tpf->denominator);
+ ap->time_base.num = tpf->numerator;
+ ap->time_base.den = tpf->denominator;
+ }
+ }
+
return 0;
}