[FFmpeg-cvslog] avfilter/vsrc_gradients: add speed option

Paul B Mahol git at videolan.org
Mon Aug 31 12:10:29 EEST 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Aug 31 11:04:38 2020 +0200| [eb9fa00bcc7138516009c6e060e07b510806fe61] | committer: Paul B Mahol

avfilter/vsrc_gradients: add speed option

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

 doc/filters.texi             | 3 +++
 libavfilter/vsrc_gradients.c | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 40d493fcae..5074538e9a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -22577,6 +22577,9 @@ for the accepted syntax.
 
 If not specified, or the expressed duration is negative, the video is
 supposed to be generated forever.
+
+ at item speed
+Set speed of gradients rotation.
 @end table
 
 
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index f62cedad8f..9de0544f5b 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -38,6 +38,7 @@ typedef struct GradientsContext {
     AVRational frame_rate;
     int64_t pts;
     int64_t duration;           ///< duration expressed in microseconds
+    float speed;
 
     uint8_t color_rgba[8][4];
     int nb_colors;
@@ -75,6 +76,7 @@ static const AVOption gradients_options[] = {
     {"seed",      "set the seed",   OFFSET(seed),          AV_OPT_TYPE_INT64,      {.i64=-1},        -1, UINT32_MAX, FLAGS },
     {"duration",  "set video duration", OFFSET(duration),  AV_OPT_TYPE_DURATION,   {.i64=-1},        -1, INT64_MAX, FLAGS },\
     {"d",         "set video duration", OFFSET(duration),  AV_OPT_TYPE_DURATION,   {.i64=-1},        -1, INT64_MAX, FLAGS },\
+    {"speed",     "set gradients rotation speed", OFFSET(speed), AV_OPT_TYPE_FLOAT,{.dbl=0.01}, 0.00001, 1, FLAGS },\
     {NULL},
 };
 
@@ -250,7 +252,7 @@ static int gradients_request_frame(AVFilterLink *outlink)
     AVFilterContext *ctx = outlink->src;
     GradientsContext *s = ctx->priv;
     AVFrame *frame = ff_get_video_buffer(outlink, s->w, s->h);
-    float angle = fmodf(s->pts / 100.f, 2.f * M_PI);
+    float angle = fmodf(s->pts * s->speed, 2.f * M_PI);
     const float w2 = s->w / 2.f;
     const float h2 = s->h / 2.f;
 



More information about the ffmpeg-cvslog mailing list