Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2015/12/28 20:02:14... | ... |
@@ -2973,6 +2973,10 @@ to remove the pauses completely. Default value is @code{0}. |
2973 | 2973 |
Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster |
2974 | 2974 |
and works better with digital silence which is exactly 0. |
2975 | 2975 |
Default value is @code{rms}. |
2976 |
+ |
|
2977 |
+@item window |
|
2978 |
+Set ratio used to calculate size of window for detecting silence. |
|
2979 |
+Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}. |
|
2976 | 2980 |
@end table |
2977 | 2981 |
|
2978 | 2982 |
@subsection Examples |
... | ... |
@@ -61,6 +61,7 @@ typedef struct SilenceRemoveContext { |
61 | 61 |
size_t stop_holdoff_end; |
62 | 62 |
int stop_found_periods; |
63 | 63 |
|
64 |
+ double window_ratio; |
|
64 | 65 |
double *window; |
65 | 66 |
double *window_current; |
66 | 67 |
double *window_end; |
... | ... |
@@ -89,6 +90,7 @@ static const AVOption silenceremove_options[] = { |
89 | 89 |
{ "detection", NULL, OFFSET(detection), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, "detection" }, |
90 | 90 |
{ "peak", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "detection" }, |
91 | 91 |
{ "rms", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "detection" }, |
92 |
+ { "window", NULL, OFFSET(window_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=0.02}, 0, 10, FLAGS }, |
|
92 | 93 |
{ NULL } |
93 | 94 |
}; |
94 | 95 |
|
... | ... |
@@ -175,7 +177,7 @@ static int config_input(AVFilterLink *inlink) |
175 | 175 |
AVFilterContext *ctx = inlink->dst; |
176 | 176 |
SilenceRemoveContext *s = ctx->priv; |
177 | 177 |
|
178 |
- s->window_size = (inlink->sample_rate / 50) * inlink->channels; |
|
178 |
+ s->window_size = FFMAX((inlink->sample_rate * s->window_ratio), 1) * inlink->channels; |
|
179 | 179 |
s->window = av_malloc_array(s->window_size, sizeof(*s->window)); |
180 | 180 |
if (!s->window) |
181 | 181 |
return AVERROR(ENOMEM); |