---
 libavdevice/bktr.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 6d49024..90161f0 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -53,10 +53,9 @@ typedef struct {
     int video_fd;
     int tuner_fd;
     int width, height;
-    int frame_rate;
-    int frame_rate_base;
     uint64_t per_frame;
     int standard;
+    AVRational fps;
 } VideoData;
 
 
@@ -246,42 +245,33 @@ static int grab_read_header(AVFormatContext *s1, 
AVFormatParameters *ap)
 {
     VideoData *s = s1->priv_data;
     AVStream *st;
-    int frame_rate;
-    int frame_rate_base;
-
-    if (ap->time_base.den <= 0)
-        return -1;
 
 #if FF_API_FORMAT_PARAMETERS
     if (ap->width > 0)
         s->width  = ap->width;
     if (ap->height > 0)
         s->height = ap->height;
+    if (ap->time_base.num)
+        s->fps = (AVRational){ ap->time_base.den, ap->time_base.num };
 #endif
     if (s->height <= 0 || s->width <= 0) {
         av_log(s1, AV_LOG_ERROR, "Invalid width/height: %dx%d", s->width, 
s->height);
         return AVERROR(EINVAL);
     }
 
-    frame_rate = ap->time_base.den;
-    frame_rate_base = ap->time_base.num;
-
     st = av_new_stream(s1, 0);
     if (!st)
         return AVERROR(ENOMEM);
     av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */
 
-    s->frame_rate = frame_rate;
-    s->frame_rate_base = frame_rate_base;
-    s->per_frame = ((uint64_t)1000000 * s->frame_rate_base) / s->frame_rate;
+    s->per_frame = ((uint64_t)1000000 * s->fps.den) / s->fps.num;
 
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->pix_fmt = PIX_FMT_YUV420P;
     st->codec->codec_id = CODEC_ID_RAWVIDEO;
     st->codec->width  = s->width;
     st->codec->height = s->height;
-    st->codec->time_base.den = frame_rate;
-    st->codec->time_base.num = frame_rate_base;
+    st->codec->time_base = (AVRational){s->fps.den, s->fps.num};
 
 #if FF_API_FORMAT_PARAMETERS
     if (ap->standard) {
@@ -332,6 +322,7 @@ static const AVOption options[] = {
     { "NTSCJ",    "", 0, FF_OPT_TYPE_CONST, {.dbl = NTSCJ}, 0, 0, 
AV_OPT_FLAG_DECODING_PARAM, "standard" },
     { "width",    "", offsetof(VideoData, width),  FF_OPT_TYPE_INT, {.dbl = 
640}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "height",   "", offsetof(VideoData, height), FF_OPT_TYPE_INT, {.dbl = 
480}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "framerate","", offsetof(VideoData, fps),    FF_OPT_TYPE_RATIONAL, {.dbl 
= 25}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
 };
 
-- 
1.7.5.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to