---
 libavdevice/vfwcap.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c
index 5734176..1f308b3 100644
--- a/libavdevice/vfwcap.c
+++ b/libavdevice/vfwcap.c
@@ -44,6 +44,7 @@ struct vfw_ctx {
     unsigned int curbufsize;
     unsigned int frame_num;
     int width, height;
+    AVRational fps;
 };
 
 static enum PixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
@@ -266,10 +267,10 @@ static int vfw_read_header(AVFormatContext *s, 
AVFormatParameters *ap)
         return AVERROR(EIO);
     }
 
-    if(!ap->time_base.den) {
-        av_log(s, AV_LOG_ERROR, "A time base must be specified.\n");
-        return AVERROR(EIO);
-    }
+#if FF_API_FORMAT_PARAMETERS
+    if (ap->time_base.num)
+        ctx->fps = (AVRational){ap->time_base.den, ap->time_base.num};
+#endif
 
     ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0);
     if(!ctx->hwnd) {
@@ -363,8 +364,7 @@ static int vfw_read_header(AVFormatContext *s, 
AVFormatParameters *ap)
     dump_captureparms(s, &cparms);
 
     cparms.fYield = 1; // Spawn a background thread
-    cparms.dwRequestMicroSecPerFrame =
-                               (ap->time_base.num*1000000) / ap->time_base.den;
+    cparms.dwRequestMicroSecPerFrame = (ctx->fps.den*1000000) / ctx->fps.num;
     cparms.fAbortLeftMouse = 0;
     cparms.fAbortRightMouse = 0;
     cparms.fCaptureAudio = 0;
@@ -376,7 +376,7 @@ static int vfw_read_header(AVFormatContext *s, 
AVFormatParameters *ap)
         goto fail_io;
 
     codec = st->codec;
-    codec->time_base = ap->time_base;
+    codec->time_base = (AVRational){ctx->fps.den, ctx->fps.num};
     codec->codec_type = AVMEDIA_TYPE_VIDEO;
     codec->width  = ctx->width;
     codec->height = ctx->height;
@@ -463,6 +463,7 @@ static int vfw_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 static const AVOption options[] = {
     { "width",    "", offsetof(struct vfw_ctx, width),  FF_OPT_TYPE_INT, {.dbl 
= 640}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "height",   "", offsetof(struct vfw_ctx, height), FF_OPT_TYPE_INT, {.dbl 
= 480}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "framerate","", offsetof(struct vfw_ctx, fps),    FF_OPT_TYPE_RATIONAL, 
{.dbl = 25}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
 };
 
-- 
1.7.5.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to