@item nb_samples, n
Set the number of samples per requested frames.
+@item duration, d
+Set the duration of the sourced audio. See
+@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
+for the accepted syntax.
+
+If not specified, or the expressed duration is negative, the audio is
+supposed to be generated forever.
@end table
@subsection Examples
uint64_t channel_layout;
char *sample_rate_str;
int sample_rate;
+ int64_t duration;
int nb_samples; ///< number of samples per requested frame
int64_t pts;
} ANullContext;
{ "r", "set sample rate", OFFSET(sample_rate_str) , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS },
{ "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
{ "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS },
+ { "duration", "set the audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
+ { "d", "set the audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
{ NULL }
};
ANullContext *null = outlink->src->priv;
AVFrame *samplesref;
+ if (null->duration >= 0 &&
+ av_rescale_q(null->pts, outlink->time_base, AV_TIME_BASE_Q) >= null->duration)
+ return AVERROR_EOF;
+
samplesref = ff_get_audio_buffer(outlink, null->nb_samples);
if (!samplesref)
return AVERROR(ENOMEM);