[FFmpeg-devel] [PATCH 2/2] lavfi: add audio silencedetect filter.
Stefano Sabatini
stefasab at gmail.com
Sun Jan 8 16:41:43 CET 2012
On date Saturday 2012-01-07 23:05:03 +0100, Clément Bœsch encoded:
> On Sat, Jan 07, 2012 at 09:37:09PM +0100, Stefano Sabatini wrote:
[...]
> > > + silence->noise = strtod(silence->noise_str, &tail);
> > > + if (!strcmp(tail, "dB"))
> > > + silence->noise = pow(10, silence->noise/20);
> >
> > Alternatively you may want to create an internal function, to share
> > with af_volume(). Also this is missing a check, in case noise_str
> > contains a foobar value.
> >
>
> I think it can be exported later; I added a check for invalid input.
OK but a shared logic would be definitively welcome and easy to
implement, also this should allow to specify a silence threshold like
e.g. "1/1000" which may be useful&consistent with volume (least
surprise rule).
[...]
> From 012f61f5f3c4e518332cbe6f3f8e9a9a8d1d923e Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
> Date: Tue, 3 Jan 2012 23:47:09 +0100
> Subject: [PATCH] lavfi: add audio silencedetect filter.
>
> ---
> Changelog | 1 +
> doc/filters.texi | 27 ++++++
> libavfilter/Makefile | 1 +
> libavfilter/af_silencedetect.c | 175 ++++++++++++++++++++++++++++++++++++++++
> libavfilter/allfilters.c | 1 +
> libavfilter/avfilter.h | 4 +-
> 6 files changed, 207 insertions(+), 2 deletions(-)
> create mode 100644 libavfilter/af_silencedetect.c
>
> diff --git a/Changelog b/Changelog
> index db4c7b3..d4ec698 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -19,6 +19,7 @@ version next:
> - Avid 1:1 10-bit RGB Packer decoder
> - v308 Quicktime Uncompressed 4:4:4 encoder and decoder
> - yuv4 libquicktime packed 4:2:0 encoder and decoder
> +- silencedetect audio filter
>
>
> version 0.9:
> diff --git a/doc/filters.texi b/doc/filters.texi
> index de73e3f..279d238 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -358,6 +358,33 @@ Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
> that should be preferred (see "-ac" option) unless you have very specific
> needs.
>
> + at section silencedetect
> +
Add a short description here: "Detect silence in the input audio." or
whatever fits you.
> +This filter logs a message when it detects that the input audio volume is less
> +or equal to the noise tolerance value set with @option{noise} for a duration
> +greater or equal to the silence duration value set with
> @option{duration}.
Maybe you can trim this very long sentence. I suggest:
This filter logs a message when it detects that the input audio volume
is less or equal to a noise tolerance value for a duration greater or
equal to the minimum detected noise duration.
noise and duration option can be specified in the option table.
> +printed times and duration are expressed in seconds.
> +
> + at table @option
> + at item duration, d
> +Set silence duration until notification (default is 2 seconds).
> +
> + at item noise, n
> +Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
> +specified value) or amplitude ratio. Default is -60dB, or 0.001.
> + at end table
> +
> +Detect 5 seconds of silence with -50dB noise tolerance:
> + at example
> +silencedetect=n=-50dB:d=5
> + at end example
> +
> +Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
> +tolerance in @file{silence.mp3}:
> + at example
> +ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
> + at end example
> +
> @section volume
[...]
Looks good otherwise.
--
FFmpeg = Furious and Frenzy Mastering Pure Ephemeral Gymnast
More information about the ffmpeg-devel
mailing list