[FFmpeg-cvslog] r25159 - trunk/libavdevice/v4l2.c

lucabe subversion
Thu Sep 23 11:16:05 CEST 2010


Author: lucabe
Date: Thu Sep 23 11:16:05 2010
New Revision: 25159

Log:
Allow to set the frame rate in v4l2 devices
Patch by Jos? Miguel Gon?alves (jose DOT goncalves AT inov DOT pt)

Modified:
   trunk/libavdevice/v4l2.c

Modified: trunk/libavdevice/v4l2.c
==============================================================================
--- trunk/libavdevice/v4l2.c	Thu Sep 23 05:40:06 2010	(r25158)
+++ trunk/libavdevice/v4l2.c	Thu Sep 23 11:16:05 2010	(r25159)
@@ -489,6 +489,33 @@ static int v4l2_set_parameters(AVFormatC
         }
     }
 
+    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;
 }
 



More information about the ffmpeg-cvslog mailing list