asetpts='(RTCTIME - RTCSTART) / (TB * 1000000)"
@end example
+@section asettb
+
+Set the timebase to use for the output frames timestamps.
+It is mainly useful for testing timebase configuration.
+
+This filter accepts the following parameters:
+
+@table @option
+
+@item expr
+The expression which is evaluated into the output timebase.
+
+@end table
+
+The expression can contain the constants @var{PI}, @var{E}, @var{PHI}, @var{AVTB} (the
+default timebase), @var{intb} (the input timebase), and @var{sr} (the sample rate,
+audio only).
+
+The default value for the input is @var{intb}.
+
+Some examples:
+
+@example
+# Set the timebase to 1/25:
+settb=1/25
+
+# Set the timebase to 1/10:
+settb=0.1
+
+# Set the timebase to 1001/1000:
+settb=1+0.001
+
+# Set the timebase to 2*intb:
+settb=2*intb
+
+# Set the default timebase value:
+settb=AVTB
+
+# Set the timebase to twice the sample rate:
+asettb=sr*2
+@end example
@section ashowinfo
REGISTER_FILTER(AMIX, amix, af);
REGISTER_FILTER(ANULL, anull, af);
REGISTER_FILTER(ASETPTS, asetpts, af);
+ REGISTER_FILTER(ASETTB, asettb, af);
REGISTER_FILTER(ASHOWINFO, ashowinfo, af);
REGISTER_FILTER(ASPLIT, asplit, af);
REGISTER_FILTER(ASYNCTS, asyncts, af);
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/rational.h"
+#include "audio.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"
"PI",
"AVTB", /* default timebase 1/AV_TIME_BASE */
"intb", /* input timebase */
+ "sr", /* sample rate */
NULL
};
VAR_PI,
VAR_AVTB,
VAR_INTB,
+ VAR_SR,
VAR_VARS_NB
};
settb->var_values[VAR_PI] = M_PI;
settb->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q);
settb->var_values[VAR_INTB] = av_q2d(inlink->time_base);
+ settb->var_values[VAR_SR] = inlink->sample_rate;
outlink->w = inlink->w;
outlink->h = inlink->h;
}
#define OFFSET(x) offsetof(SetTBContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM
static const AVOption options[] = {
{ "expr", "Expression determining the output timebase", OFFSET(tb_expr), AV_OPT_TYPE_STRING, { .str = "intb" }, .flags = FLAGS },
{ NULL },
};
+#if CONFIG_SETTB_FILTER
static const AVClass settb_class = {
.class_name = "settb",
.item_name = av_default_item_name,
AVFilter ff_vf_settb = {
.name = "settb",
- .description = NULL_IF_CONFIG_SMALL("Set timebase for the output link."),
+ .description = NULL_IF_CONFIG_SMALL("Set timebase for the video output link."),
.priv_size = sizeof(SetTBContext),
.priv_class = &settb_class,
.outputs = avfilter_vf_settb_outputs,
};
+#endif /* CONFIG_SETTB_FILTER */
+
+#if CONFIG_ASETTB_FILTER
+static const AVClass asettb_class = {
+ .class_name = "asettb",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+static const AVFilterPad avfilter_af_asettb_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .get_audio_buffer = ff_null_get_audio_buffer,
+ .filter_frame = filter_frame,
+ },
+ { NULL }
+};
+
+static const AVFilterPad avfilter_af_asettb_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .config_props = config_output_props,
+ },
+ { NULL }
+};
+
+AVFilter ff_af_asettb = {
+ .name = "asettb",
+ .description = NULL_IF_CONFIG_SMALL("Set timebase for the audio output link."),
+ .priv_size = sizeof(SetTBContext),
+ .inputs = avfilter_af_asettb_inputs,
+ .outputs = avfilter_af_asettb_outputs,
+ .priv_class = &asettb_class,
+};
+#endif /* CONFIG_ASETTB_FILTER */