aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_random.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-01-27 22:43:59 +0100
committerPaul B Mahol <onemda@gmail.com>2023-01-27 23:01:52 +0100
commit7b78684f9638b5f78766298fc4583c9a4d80d5ad (patch)
treebd23896f764db22e1810c689e2189bdf1fc8f056 /libavfilter/vf_random.c
parenta749e43c86ea4fd217b035538435ba16956a729c (diff)
downloadffmpeg-7b78684f9638b5f78766298fc4583c9a4d80d5ad.tar.gz
avfilter/vf_random: set output frame duration
Diffstat (limited to 'libavfilter/vf_random.c')
-rw-r--r--libavfilter/vf_random.c6
1 files changed, 6 insertions, 0 deletions
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;