[FFmpeg-cvslog] avfilter/f_loop: make sure duration of frame is never zero

Paul B Mahol git at videolan.org
Fri Nov 2 12:26:35 EET 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Nov  2 11:20:30 2018 +0100| [4620e4c7ad2fd19d0bbe17c25c3466c40cc97279] | committer: Paul B Mahol

avfilter/f_loop: make sure duration of frame is never zero

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4620e4c7ad2fd19d0bbe17c25c3466c40cc97279
---

 libavfilter/f_loop.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 255fe643da..1f857abf8d 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -267,7 +267,7 @@ static int push_frame(AVFilterContext *ctx)
 {
     AVFilterLink *outlink = ctx->outputs[0];
     LoopContext *s = ctx->priv;
-    int64_t pts;
+    int64_t pts, duration;
     int ret;
 
     AVFrame *out = av_frame_clone(s->frames[s->current_frame]);
@@ -275,7 +275,11 @@ static int push_frame(AVFilterContext *ctx)
     if (!out)
         return AVERROR(ENOMEM);
     out->pts += s->duration - s->start_pts;
-    pts = out->pts + out->pkt_duration;
+    if (out->pkt_duration)
+        duration = out->pkt_duration;
+    else
+        duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base);
+    pts = out->pts + duration;
     ret = ff_filter_frame(outlink, out);
     s->current_frame++;
 
@@ -295,6 +299,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     AVFilterContext *ctx = inlink->dst;
     AVFilterLink *outlink = ctx->outputs[0];
     LoopContext *s = ctx->priv;
+    int64_t duration;
     int ret = 0;
 
     if (inlink->frame_count_out >= s->start && s->size > 0 && s->loop != 0) {
@@ -307,7 +312,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
                 return AVERROR(ENOMEM);
             }
             s->nb_frames++;
-            s->duration = frame->pts + frame->pkt_duration;
+            if (frame->pkt_duration)
+                duration = frame->pkt_duration;
+            else
+                duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base);
+            s->duration = frame->pts + duration;
             ret = ff_filter_frame(outlink, frame);
         } else {
             av_frame_free(&frame);



More information about the ffmpeg-cvslog mailing list