aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-02 00:11:16 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-03-07 04:04:07 +0100
commit51231fa6f6e8daddf56be89bbfd509aeb94ccf2c (patch)
tree6b4c656ef3df9808262222db387a6de924aebbbf
parentc6a4083c29e00f769b770964016f694f55c1560c (diff)
downloadffmpeg-51231fa6f6e8daddf56be89bbfd509aeb94ccf2c.tar.gz
avdevice/v4l2: only use average frame rate if set
It might be unset on some platforms with some drivers and some input Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 0997c2504b25cbc2856800fc063395dcd40b2bf7) Conflicts: libavdevice/v4l2.c
-rw-r--r--libavdevice/v4l2.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 00686a490d..002329e14e 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -495,16 +495,18 @@ static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
return 0;
}
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
- now = av_gettime_monotonic();
- if (s->ts_mode == V4L_TS_MONO2ABS ||
- (ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE)) {
- int64_t period = av_rescale_q(1, ctx->streams[0]->codec->time_base,
- AV_TIME_BASE_Q);
- av_log(ctx, AV_LOG_INFO, "Detected monotonic timestamps, converting\n");
- /* microseconds instead of seconds, MHz instead of Hz */
- s->timefilter = ff_timefilter_new(1, period, 1.0E-6);
- s->ts_mode = V4L_TS_CONVERT_READY;
- return 0;
+ if (ctx->streams[0]->codec->time_base.den) {
+ now = av_gettime_monotonic();
+ if (s->ts_mode == V4L_TS_MONO2ABS ||
+ (ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE)) {
+ int64_t period = av_rescale_q(1, ctx->streams[0]->codec->time_base,
+ AV_TIME_BASE_Q);
+ av_log(ctx, AV_LOG_INFO, "Detected monotonic timestamps, converting\n");
+ /* microseconds instead of seconds, MHz instead of Hz */
+ s->timefilter = ff_timefilter_new(1, period, 1.0E-6);
+ s->ts_mode = V4L_TS_CONVERT_READY;
+ return 0;
+ }
}
#endif
av_log(ctx, AV_LOG_ERROR, "Unknown timestamps\n");
@@ -892,7 +894,8 @@ static int v4l2_read_header(AVFormatContext *s1)
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
st->codec->width = s->width;
st->codec->height = s->height;
- st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
+ if (st->codec->time_base.num)
+ st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
out:
return res;