[FFmpeg-devel] [PATCH] add silenceremove filter

Timothy Gu timothygu99 at gmail.com
Sun Aug 31 20:43:35 CEST 2014


On Aug 29, 2014 11:23 AM, "Paul B Mahol" <onemda at gmail.com> wrote:
>
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  doc/filters.texi               |  62 ++++++
>  libavfilter/Makefile           |   1 +
>  libavfilter/af_silenceremove.c | 478
+++++++++++++++++++++++++++++++++++++++++
>  libavfilter/allfilters.c       |   1 +
>  4 files changed, 542 insertions(+)
>  create mode 100644 libavfilter/af_silenceremove.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index cca15fc..ea7da88 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -1881,6 +1881,68 @@ ffmpeg -i silence.mp3 -af
silencedetect=noise=0.0001 -f null -
>  @end example
>  @end itemize
>
> + at section silenceremove
> +
> +Removes silence from the beginning, middle or end of the audio.
> +

@subsection Options

> +The filter accepts the following options:
> +
> + at table @option
> + at item start_periods

> +This value is used to indicate if audio should be trimmed at beginning of
> +the audio.

... and how much silence to trim.

> A value of zero indicates no silence should be trimmed from the
> +beginning.

> When specifying an non-zero value, it trims audio up until it
> +finds non-silence. Normally, when trimming silence from beginning of
audio
> +the @var{start_periods} will be @code{1} but it can be increased to
higher
> +values to trim all audio up to specific count of non-silence periods.

Is this better?

---
When a nonzero value is specified, audio is trimmed until the specified
count of non-silence periods is reached.

Normally you would use 1 which means that trimming is stopped as soon as
non-silence is reached.
---

What if I have an audio segment like this, with start_periods==2 and
start_duration==4? What will get trimmed and what will not?

Silence5sec Noise1sec Silence2sec Noise5sec Silence5sec Noise5sec
Silence1sec NoiseForever

> +
> + at item start_duration
> +Specify amount of time that non-silence must be detected before it stops

> +trimming audio. By increasing the duration, burst of noise can be treated

bursts of noises

> +as silence and trimmed off.
> +

> + at item start_threshold

> +This indicate what sample value should be treated as silence. For digital

indicate_s_ how "silent" a segment must be to be treated as silence.

> +audio, a value of @code{0} may be fine but for audio recorded from
analog,
> +you may wish to increase the value to account for background noise.

> +
> + at item stop_periods
> +Set the count for trimming silence from the end of audio.
> +To remove silence from the middle of a file, specify a @var{stop_periods}

> +that is negative. This value is the threated as a positive value and is
also

threated

> +used to indicate the effect should restart processing as specified by
> + at var{start_periods}, making it suitable for removing periods of silence
> +in the middle of the audio.
> +
> + at item stop_duration
> +Specify a duration of silence that must exist before audio is not copied
any
> +more. By specifying a higher duration, silence that is wanted can be left
> +in the audio.
> +
> + at item stop_threshold

> +This indicate what sample value should be treated as silence but for
> +trimming silence from the end of audio.

This the same as @option {start_threshold} but for trimming...

> +
> + at item leave_silence
> +This indicate that @var{stop_duration} length of audio should be left
intact
> +at the beginning of each period of silence.
> +For example, if you want to remove long pauses between words but do not
want
> +to remove the pauses completely.
> +
> + at end table
> +
> + at subsection Examples
> +
> + at itemize
> + at item
> +The following example shows how this filter can be used to start
recording
> +that does not contain the delay at the start which usually occurs between

> +pressing the record button and the star of the performance:

start

> + at example
> +silenceremove=1:5:0.02

What are these values? I.e. can you show is in a named form too?

> + at end example
> + at end itemize
> +

More review might follow if you answer my question above.

Timothy


More information about the ffmpeg-devel mailing list