[FFmpeg-devel] [PATCH] avfilter/mandelbrot: add duration option.
Clément Bœsch
u at pkh.me
Sun May 4 11:08:01 CEST 2014
---
doc/filters.texi | 3 +++
libavfilter/vsrc_mandelbrot.c | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 923551f..265b6b8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8914,6 +8914,9 @@ Default value is @var{normalized_iteration_count}.
Set frame rate, expressed as number of frames per second. Default
value is "25".
+ at item duration, d
+Specify the duration of the generated audio stream.
+
@item size, s
Set frame size. For the syntax of this option, check the "Video
size" section in the ffmpeg-utils manual. Default value is "640x480".
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 19dddf9..b67e695 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -61,6 +61,7 @@ typedef struct {
const AVClass *class;
int w, h;
AVRational frame_rate;
+ int64_t duration;
uint64_t pts;
int maxiter;
double start_x;
@@ -91,6 +92,8 @@ static const AVOption mandelbrot_options[] = {
{"s", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="640x480"}, CHAR_MIN, CHAR_MAX, FLAGS },
{"rate", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, CHAR_MIN, CHAR_MAX, FLAGS },
{"r", "set frame rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, CHAR_MIN, CHAR_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 },
{"maxiter", "set max iterations number", OFFSET(maxiter), AV_OPT_TYPE_INT, {.i64=7189}, 1, INT_MAX, FLAGS },
{"start_x", "set the initial x position", OFFSET(start_x), AV_OPT_TYPE_DOUBLE, {.dbl=-0.743643887037158704752191506114774}, -100, 100, FLAGS },
{"start_y", "set the initial y position", OFFSET(start_y), AV_OPT_TYPE_DOUBLE, {.dbl=-0.131825904205311970493132056385139}, -100, 100, FLAGS },
@@ -396,7 +399,13 @@ static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize,
static int request_frame(AVFilterLink *link)
{
MBContext *mb = link->src->priv;
- AVFrame *picref = ff_get_video_buffer(link, mb->w, mb->h);
+ AVFrame *picref;
+
+ if (mb->duration >= 0 &&
+ av_rescale_q(mb->pts, link->time_base, AV_TIME_BASE_Q) >= mb->duration)
+ return AVERROR_EOF;
+
+ picref = ff_get_video_buffer(link, mb->w, mb->h);
if (!picref)
return AVERROR(ENOMEM);
--
1.9.2
More information about the ffmpeg-devel
mailing list