avdevice/v4l2: only use frame period from v4l2 if valid
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 1 Feb 2014 23:10:43 +0000 (00:10 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 1 Feb 2014 23:13:01 +0000 (00:13 +0100)
There is evidence that some drivers do not set a valid value

See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718805
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavdevice/v4l2.c

index 1ab6f1c..b4f65d3 100644 (file)
@@ -742,9 +742,12 @@ static int v4l2_set_parameters(AVFormatContext *s1)
                    "The driver does not allow to change time per frame\n");
         }
     }
-    s1->streams[0]->avg_frame_rate.num = tpf->denominator;
-    s1->streams[0]->avg_frame_rate.den = tpf->numerator;
-    s1->streams[0]->r_frame_rate = s1->streams[0]->avg_frame_rate;
+    if (tpf->denominator > 0 && tpf->numerator > 0) {
+        s1->streams[0]->avg_frame_rate.num = tpf->denominator;
+        s1->streams[0]->avg_frame_rate.den = tpf->numerator;
+        s1->streams[0]->r_frame_rate = s1->streams[0]->avg_frame_rate;
+    } else
+        av_log(s1, AV_LOG_WARNING, "Time per frame unknown\n");
 
     return 0;
 }