> +static int filter_frame(AVFilterLink *inlink, AVFrame *frame) > +{ > + AVFilterContext *ctx = inlink->dst; > + RealtimeContext *s = ctx->priv; > + > + if (frame->pts != AV_NOPTS_VALUE) { > + int64_t pts = av_rescale_q(frame->pts, inlink->time_base, > AV_TIME_BASE_Q); > + int64_t now = av_gettime_relative(); > + int64_t sleep = pts - now + s->delta; > + if (!s->inited) { > + s->inited = 1; > + sleep = 0; > + s->delta = now - pts; > + } > + if (sleep > s->limit || sleep < -s->limit) { > + av_log(ctx, AV_LOG_WARNING, > + "time discontinuity detected: %"PRIi64" us, resetting\n", > + sleep);
Won't this also be shown when there is no discontinuity but it isn't able to keep up with realtime (e.g. due to a very high frame rate)? The message is misleading in that situation. > + sleep = 0; > + s->delta = now - pts; > + } > + if (sleep > 0) { > + av_log(ctx, AV_LOG_DEBUG, "sleeping %"PRIi64" us\n", sleep); > + av_usleep(sleep); > + } > + } > + return ff_filter_frame(inlink->dst->outputs[0], frame); > +} > + > +#define OFFSET(x) offsetof(RealtimeContext, x) > +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | > AV_OPT_FLAG_FILTERING_PARAM > +static const AVOption options[] = { > + { "limit", "sleep time limit", OFFSET(limit), AV_OPT_TYPE_DURATION, { > .i64 = 2000000 }, 0, INT64_MAX, FLAGS }, > + { NULL } > +}; The argument to av_usleep() is an unsigned int. Should the maximum limit be UINT_MAX rather than INT64_MAX? Alternatively it could call av_usleep() in a loop if the value is too large for one call. - Mark _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel