[FFmpeg-cvslog] avfilter/vf_random: set output frame duration

Paul B Mahol git at videolan.org
Fri Jan 27 23:57:20 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Jan 27 22:43:59 2023 +0100| [7b78684f9638b5f78766298fc4583c9a4d80d5ad] | committer: Paul B Mahol

avfilter/vf_random: set output frame duration

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

 libavfilter/vf_random.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/vf_random.c b/libavfilter/vf_random.c
index b3acdd1fcf..cb4b3d3827 100644
--- a/libavfilter/vf_random.c
+++ b/libavfilter/vf_random.c
@@ -37,6 +37,7 @@ typedef struct RandomContext {
     int nb_frames_filled;
     AVFrame *frames[MAX_FRAMES];
     int64_t pts[MAX_FRAMES];
+    int64_t duration[MAX_FRAMES];
     int flush_idx;
 } RandomContext;
 
@@ -74,6 +75,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     if (s->nb_frames_filled < s->nb_frames) {
         s->frames[s->nb_frames_filled] = in;
+        s->duration[s->nb_frames_filled] = in->duration;
         s->pts[s->nb_frames_filled++] = in->pts;
         return 0;
     }
@@ -82,9 +84,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     out = s->frames[idx];
     out->pts = s->pts[0];
+    out->duration = s->duration[0];
     memmove(&s->pts[0], &s->pts[1], (s->nb_frames - 1) * sizeof(s->pts[0]));
+    memmove(&s->duration[0], &s->duration[1], (s->nb_frames - 1) * sizeof(s->duration[0]));
     s->frames[idx] = in;
     s->pts[s->nb_frames - 1] = in->pts;
+    s->duration[s->nb_frames - 1] = in->duration;
 
     return ff_filter_frame(outlink, out);
 }
@@ -104,6 +109,7 @@ next:
             s->nb_frames--;
             goto next;
         }
+        out->duration = s->duration[s->flush_idx];
         out->pts = s->pts[s->flush_idx++];
         ret = ff_filter_frame(outlink, out);
         s->frames[s->nb_frames - 1] = NULL;



More information about the ffmpeg-cvslog mailing list