FFmpeg
Loading...
Searching...
No Matches
af_silenceremove.c File Reference
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "filters.h"
#include "avfilter.h"
#include "silenceremove_template.c"

Go to the source code of this file.

Data Structures

struct  SilenceRemoveContext
 

Macros

#define OFFSET(x)
 
#define AF   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 
#define AFR   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define DEPTH   32
 
#define DEPTH   64
 

Enumerations

enum  SilenceDetect {
  D_AVG , D_RMS , D_PEAK , D_MEDIAN ,
  D_PTP , D_DEV , D_NB
}
 
enum  TimestampMode { TS_WRITE , TS_COPY , TS_NB }
 
enum  ThresholdMode { T_ANY , T_ALL }
 

Functions

 AVFILTER_DEFINE_CLASS (silenceremove)
 
static av_cold int init (AVFilterContext *ctx)
 
static void clear_windows (SilenceRemoveContext *s)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *outlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption silenceremove_options []
 
static const AVFilterPad silenceremove_inputs []
 
static const AVFilterPad silenceremove_outputs []
 
const FFFilter ff_af_silenceremove
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 125 of file af_silenceremove.c.

◆ AF

Definition at line 126 of file af_silenceremove.c.

◆ AFR

◆ DEPTH [1/2]

#define DEPTH   32

Definition at line 158 of file af_silenceremove.c.

◆ DEPTH [2/2]

#define DEPTH   64

Definition at line 158 of file af_silenceremove.c.

Enumeration Type Documentation

◆ SilenceDetect

Enumerator
D_AVG 
D_RMS 
D_PEAK 
D_MEDIAN 
D_PTP 
D_DEV 
D_NB 

Definition at line 33 of file af_silenceremove.c.

◆ TimestampMode

Enumerator
TS_WRITE 
TS_COPY 
TS_NB 

Definition at line 43 of file af_silenceremove.c.

◆ ThresholdMode

Enumerator
T_ANY 
T_ALL 

Definition at line 49 of file af_silenceremove.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( silenceremove )

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 165 of file af_silenceremove.c.

◆ clear_windows()

static void clear_windows ( SilenceRemoveContext * s)
static

Definition at line 177 of file af_silenceremove.c.

Referenced by config_output().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 198 of file af_silenceremove.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 223 of file af_silenceremove.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * outlink,
AVFrame * in )
static

Definition at line 294 of file af_silenceremove.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 416 of file af_silenceremove.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 448 of file af_silenceremove.c.

Variable Documentation

◆ silenceremove_options

const AVOption silenceremove_options[]
static
Initial value:
= {
{ "start_periods", "set periods of silence parts to skip from start", OFFSET(start_periods), AV_OPT_TYPE_INT, {.i64=0}, 0, 9000, AF },
{ "start_duration", "set start duration of non-silence part", OFFSET(start_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "start_threshold", "set threshold for start silence detection", OFFSET(start_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AFR },
{ "start_silence", "set start duration of silence part to keep", OFFSET(start_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "start_mode", "set which channel will trigger trimming from start", OFFSET(start_mode), AV_OPT_TYPE_INT, {.i64=T_ANY}, T_ANY, T_ALL, AFR, .unit = "mode" },
{ "any", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ANY}, 0, 0, AFR, .unit = "mode" },
{ "all", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ALL}, 0, 0, AFR, .unit = "mode" },
{ "stop_periods", "set periods of silence parts to skip from end", OFFSET(stop_periods), AV_OPT_TYPE_INT, {.i64=0}, -9000, 9000, AF },
{ "stop_duration", "set stop duration of silence part", OFFSET(stop_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "stop_threshold", "set threshold for stop silence detection", OFFSET(stop_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AFR },
{ "stop_silence", "set stop duration of silence part to keep", OFFSET(stop_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF },
{ "stop_mode", "set which channel will trigger trimming from end", OFFSET(stop_mode), AV_OPT_TYPE_INT, {.i64=T_ALL}, T_ANY, T_ALL, AFR, .unit = "mode" },
{ "detection", "set how silence is detected", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=D_RMS}, 0, D_NB-1, AF, .unit = "detection" },
{ "avg", "use mean absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_AVG}, 0, 0, AF, .unit = "detection" },
{ "rms", "use root mean squared values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_RMS}, 0, 0, AF, .unit = "detection" },
{ "peak", "use max absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_PEAK},0, 0, AF, .unit = "detection" },
{ "median", "use median of absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_MEDIAN},0, 0, AF, .unit = "detection" },
{ "ptp", "use absolute of max peak to min peak difference", 0, AV_OPT_TYPE_CONST, {.i64=D_PTP}, 0, 0, AF, .unit = "detection" },
{ "dev", "use standard deviation from values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_DEV}, 0, 0, AF, .unit = "detection" },
{ "window", "set duration of window for silence detection", OFFSET(window_duration_opt), AV_OPT_TYPE_DURATION, {.i64=20000}, 0, 100000000, AF },
{ "timestamp", "set how every output frame timestamp is processed", OFFSET(timestamp_mode), AV_OPT_TYPE_INT, {.i64=TS_WRITE}, 0, TS_NB-1, AF, .unit = "timestamp" },
{ "write", "full timestamps rewrite, keep only the start time", 0, AV_OPT_TYPE_CONST, {.i64=TS_WRITE}, 0, 0, AF, .unit = "timestamp" },
{ "copy", "non-dropped frames are left with same timestamp", 0, AV_OPT_TYPE_CONST, {.i64=TS_COPY}, 0, 0, AF, .unit = "timestamp" },
{ NULL }
}
#define AF
#define AFR
Definition af_afftdn.c:165
@ D_PTP
@ D_NB
@ D_PEAK
@ D_DEV
@ D_MEDIAN
@ D_AVG
@ D_RMS
@ T_ANY
@ T_ALL
@ TS_COPY
@ TS_NB
@ TS_WRITE
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition opt.h:318
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266

Definition at line 129 of file af_silenceremove.c.

◆ silenceremove_inputs

const AVFilterPad silenceremove_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 465 of file af_silenceremove.c.

◆ silenceremove_outputs

const AVFilterPad silenceremove_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 473 of file af_silenceremove.c.

◆ ff_af_silenceremove

const FFFilter ff_af_silenceremove
Initial value:
= {
.p.name = "silenceremove",
.p.description = NULL_IF_CONFIG_SMALL("Remove silence."),
.p.priv_class = &silenceremove_class,
.priv_size = sizeof(SilenceRemoveContext),
.init = init,
.process_command = ff_filter_process_command,
}
static const AVFilterPad silenceremove_outputs[]
static const AVFilterPad silenceremove_inputs[]
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition avfilter.c:906
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition avfilter.h:204
@ AV_SAMPLE_FMT_FLT
float
Definition samplefmt.h:60
@ AV_SAMPLE_FMT_DBL
double
Definition samplefmt.h:61
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_SAMPLEFMTS(...)
Definition filters.h:252
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 481 of file af_silenceremove.c.