mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-17 04:17:05 +00:00
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>
This commit is contained in:
parent
4aa4533ee8
commit
0997c2504b
@ -447,18 +447,20 @@ static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
|
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
|
||||||
now = av_gettime_monotonic();
|
if (ctx->streams[0]->avg_frame_rate.num) {
|
||||||
if (s->ts_mode == V4L_TS_MONO2ABS ||
|
now = av_gettime_monotonic();
|
||||||
(ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE)) {
|
if (s->ts_mode == V4L_TS_MONO2ABS ||
|
||||||
AVRational tb = {AV_TIME_BASE, 1};
|
(ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 * AV_TIME_BASE)) {
|
||||||
int64_t period = av_rescale_q(1, tb, ctx->streams[0]->avg_frame_rate);
|
AVRational tb = {AV_TIME_BASE, 1};
|
||||||
av_log(ctx, AV_LOG_INFO, "Detected monotonic timestamps, converting\n");
|
int64_t period = av_rescale_q(1, tb, ctx->streams[0]->avg_frame_rate);
|
||||||
/* microseconds instead of seconds, MHz instead of Hz */
|
av_log(ctx, AV_LOG_INFO, "Detected monotonic timestamps, converting\n");
|
||||||
s->timefilter = ff_timefilter_new(1, period, 1.0E-6);
|
/* microseconds instead of seconds, MHz instead of Hz */
|
||||||
if (!s->timefilter)
|
s->timefilter = ff_timefilter_new(1, period, 1.0E-6);
|
||||||
return AVERROR(ENOMEM);
|
if (!s->timefilter)
|
||||||
s->ts_mode = V4L_TS_CONVERT_READY;
|
return AVERROR(ENOMEM);
|
||||||
return 0;
|
s->ts_mode = V4L_TS_CONVERT_READY;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
av_log(ctx, AV_LOG_ERROR, "Unknown timestamps\n");
|
av_log(ctx, AV_LOG_ERROR, "Unknown timestamps\n");
|
||||||
@ -949,7 +951,8 @@ static int v4l2_read_header(AVFormatContext *s1)
|
|||||||
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
|
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
|
||||||
st->codec->width = s->width;
|
st->codec->width = s->width;
|
||||||
st->codec->height = s->height;
|
st->codec->height = s->height;
|
||||||
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
|
if (st->avg_frame_rate.den)
|
||||||
|
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user