44 int nb_samples, int64_t nb_samples_notify,
48 #define OFFSET(x) offsetof(SilenceDetectContext, x)
49 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
67 int is_silence, int64_t nb_samples_notify,
88 "silence_end: %s | silence_duration: %s\n",
96 #define SILENCE_DETECT(name, type) \
97 static void silencedetect_##name(SilenceDetectContext *s, AVFrame *insamples, \
98 int nb_samples, int64_t nb_samples_notify, \
99 AVRational time_base) \
101 const type *p = (const type *)insamples->data[0]; \
102 const type noise = s->noise; \
105 for (i = 0; i < nb_samples; i++, p++) \
106 update(s, insamples, *p < noise && *p > -noise, \
107 nb_samples_notify, time_base); \
120 switch (inlink->format) {
124 s->
noise *= INT32_MAX;
128 s->
noise *= INT16_MAX;
150 s->
silencedetect(s, insamples, nb_samples, nb_samples_notify,
208 .
name =
"silencedetect",
212 .
inputs = silencedetect_inputs,
213 .
outputs = silencedetect_outputs,
214 .priv_class = &silencedetect_class,
This structure describes decoded (raw) audio or video data.
static int noise(AVBSFContext *ctx, AVPacket *out)
Main libavfilter public API header.
#define SILENCE_DETECT(name, type)
AVFilter ff_af_silencedetect
const char * name
Pad name.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
timestamp utils, mostly useful for debugging/logging purposes
static const AVFilterPad silencedetect_inputs[]
double duration
minimum duration of silence until notification
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
AVDictionary * metadata
metadata.
A filter pad used for either input or output.
static char * get_metadata_val(AVFrame *insamples, const char *key)
A link between two filters.
int sample_rate
samples per second
static const AVFilterPad silencedetect_outputs[]
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int64_t start
if silence is detected, this value contains the time of the first zero sample
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int64_t nb_samples_notify, AVRational time_base)
double noise
noise amplitude ratio
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static int config_input(AVFilterLink *inlink)
static const AVFilterPad outputs[]
A list of supported channel layouts.
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
AVFILTER_DEFINE_CLASS(silencedetect)
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
static int query_formats(AVFilterContext *ctx)
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
void(* silencedetect)(struct SilenceDetectContext *s, AVFrame *insamples, int nb_samples, int64_t nb_samples_notify, AVRational time_base)
int channels
Number of channels.
int64_t nb_null_samples
current number of continuous zero samples
static const AVOption silencedetect_options[]
AVFilterContext * dst
dest filter
static enum AVSampleFormat sample_fmts[]
int last_sample_rate
last sample rate to check for sample rate changes
int nb_samples
number of audio samples (per channel) described by this frame