From 23d0214939aedc77ab60d799cac4847d692358d5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 27 Jan 2023 22:56:13 +0100 Subject: [PATCH] avfilter/vf_tpad: set output frame duration --- libavfilter/vf_tpad.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c index c870478158..f0c065f0c3 100644 --- a/libavfilter/vf_tpad.c +++ b/libavfilter/vf_tpad.c @@ -75,7 +75,7 @@ static int activate(AVFilterContext *ctx) TPadContext *s = ctx->priv; AVFrame *frame = NULL; int ret, status; - int64_t pts; + int64_t duration, pts; FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); @@ -98,8 +98,10 @@ static int activate(AVFilterContext *ctx) ff_fill_rectangle(&s->draw, &s->color, frame->data, frame->linesize, 0, 0, frame->width, frame->height); + duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); frame->pts = s->pts; - s->pts += av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); + frame->duration = duration; + s->pts += duration; s->pad_start--; return ff_filter_frame(outlink, frame); } @@ -116,8 +118,10 @@ static int activate(AVFilterContext *ctx) frame = av_frame_clone(s->cache_start); if (!frame) return AVERROR(ENOMEM); + duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); frame->pts = s->pts; - s->pts += av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); + frame->duration = duration; + s->pts += duration; s->pad_start--; if (s->pad_start == 0) s->cache_start = NULL; @@ -160,8 +164,10 @@ static int activate(AVFilterContext *ctx) if (!frame) return AVERROR(ENOMEM); } + duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); frame->pts = s->pts; - s->pts += av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); + frame->duration = duration; + s->pts += duration; if (s->pad_stop > 0) s->pad_stop--; return ff_filter_frame(outlink, frame);