Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-12-17 Thread Michael Niedermayer
On Mon, Oct 31, 2016 at 11:13:28AM -0400, Greg Rowe wrote:
> On 2016-10-18 2:20 PM, Michael Niedermayer wrote:
> >On Tue, Oct 18, 2016 at 12:46:56PM -0400, Greg Rowe wrote:
> >>>see
> >>>libavfilter/asrc_sine.c
> >>>this code should probably be reused / factored
> >>>(note, any code moving/factoring of existing code should be in a
> >>>seperate patch)
> >>
> >>Since silenceremove works only on AV_SAMPLE_FMT_DBL is it OK to use
> >>floating point for the generated tone or is it recommended to create
> >>the tone and then convert it to double samples or some other
> >>approach?
> >
> >can you write a fate test for the filter which is portable accross
> >platforms ?
> >
> >every filter should ideally have a fate test.
> >If you can write a working an portable fate test with float sine
> >then i have no objections to it
> 
> Do you have ideas on how I could implement this feature while
> avoiding floating point (or at least to implemented the feature in a
> portable manner)?  I agree that it would be better but I'm not sure
> how to do it.
> 
> I could change the entire silence remove filter to avoid floating
> point ops but that would be a big change and I don't think that's a
> good idea.
> 
> Would it work if I created the tone using asrc_since.c and then
> converted that to double samples within the filter?  (rather than my
> existing approach which generates the tone as doubles using sin()).

fate supports comparing things to a reference file
using a short 1sec file at low sampling rate should also be neglible
in file size, so float can be used if you prefer.
still it should only be used where it makes sense (sine) not for
anything timestamp related



[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-31 Thread Greg Rowe

On 2016-10-18 2:20 PM, Michael Niedermayer wrote:

On Tue, Oct 18, 2016 at 12:46:56PM -0400, Greg Rowe wrote:

see
libavfilter/asrc_sine.c
this code should probably be reused / factored
(note, any code moving/factoring of existing code should be in a
seperate patch)


Since silenceremove works only on AV_SAMPLE_FMT_DBL is it OK to use
floating point for the generated tone or is it recommended to create
the tone and then convert it to double samples or some other
approach?


can you write a fate test for the filter which is portable accross
platforms ?

every filter should ideally have a fate test.
If you can write a working an portable fate test with float sine
then i have no objections to it


Do you have ideas on how I could implement this feature while avoiding 
floating point (or at least to implemented the feature in a portable 
manner)?  I agree that it would be better but I'm not sure how to do it.


I could change the entire silence remove filter to avoid floating point 
ops but that would be a big change and I don't think that's a good idea.


Would it work if I created the tone using asrc_since.c and then 
converted that to double samples within the filter?  (rather than my 
existing approach which generates the tone as doubles using sin()).


Thanks,
Greg

--
Greg Rowe
www.shoretel.com


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-18 Thread Michael Niedermayer
On Tue, Oct 18, 2016 at 12:46:56PM -0400, Greg Rowe wrote:
> >see
> >libavfilter/asrc_sine.c
> >this code should probably be reused / factored
> >(note, any code moving/factoring of existing code should be in a
> > seperate patch)
> 
> Since silenceremove works only on AV_SAMPLE_FMT_DBL is it OK to use
> floating point for the generated tone or is it recommended to create
> the tone and then convert it to double samples or some other
> approach?

can you write a fate test for the filter which is portable accross
platforms ?

every filter should ideally have a fate test.
If you can write a working an portable fate test with float sine
then i have no objections to it

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-18 Thread Greg Rowe

see
libavfilter/asrc_sine.c
this code should probably be reused / factored
(note, any code moving/factoring of existing code should be in a
 seperate patch)


Since silenceremove works only on AV_SAMPLE_FMT_DBL is it OK to use 
floating point for the generated tone or is it recommended to create the 
tone and then convert it to double samples or some other approach?



Thanks,
Greg

--
Greg Rowe
www.shoretel.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-14 Thread Michael Niedermayer
On Fri, Oct 14, 2016 at 06:09:51PM +, Greg Rowe wrote:
> Michael,
> 
> In the attached patch I've tried to make all of the changes you've pointed 
> out.  I also renamed tone_hz to tone_frequency on Moritz Barsnick's 
> suggestion.
> 
> Is there a good way to generate the tone while avoiding floating point 
> operations?  If there is then don't bother reviewing this patch and I'll make 
> that change once I know better how to do it.

see
libavfilter/asrc_sine.c
this code should probably be reused / factored
(note, any code moving/factoring of existing code should be in a
 seperate patch)

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-14 Thread Greg Rowe

On Fri, Oct 14, 2016 at 18:09:51 +, Greg Rowe wrote:
You attached the old patch. ;-)


Is there a good way to generate the tone while avoiding floating
point operations?


Well that's embarrassing.  I'll fix that after we figure out how best to 
handle the tone generation.  :)




Good point: libavfilter/asrc_sine.c does exactly that, if I understand
the code correctly. And avoids math.h's sin() by creating a lookup
table. (I'm not sure whether your patch should have included math.h
explicitly. It was probably pulled in via avutil headers.)

Now I think you would be duplicating some stuff from there. Perhaps
something to be put into common functions and reused?


I saw that today.  There is also ff_generate_wave_table which I *think* 
is applicable but I'm not certain and didn't have the time yet to play with.




I removed the unrelated changes.


They might be worthwhile anyway, later then.


I'll submit a patch for those changes after this one get straightened 
out.  I have a patch I'd like to submit for the Sky Media format (a 
container format we use at Shoretel).  I thought I'd get my feet wet 
with this change first!


Thanks,
Greg

--
Greg Rowe
www.shoretel.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-14 Thread Moritz Barsnick
On Fri, Oct 14, 2016 at 18:09:51 +, Greg Rowe wrote:
> In the attached patch I've tried to make all of the changes you've
> pointed out. I also renamed tone_hz to tone_frequency on Moritz
> Barsnick's suggestion.

You attached the old patch. ;-)

> Is there a good way to generate the tone while avoiding floating
> point operations?

Good point: libavfilter/asrc_sine.c does exactly that, if I understand
the code correctly. And avoids math.h's sin() by creating a lookup
table. (I'm not sure whether your patch should have included math.h
explicitly. It was probably pulled in via avutil headers.)

Now I think you would be duplicating some stuff from there. Perhaps
something to be put into common functions and reused?

> I removed the unrelated changes.

They might be worthwhile anyway, later then.

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-14 Thread Greg Rowe
Michael,

In the attached patch I've tried to make all of the changes you've pointed out. 
 I also renamed tone_hz to tone_frequency on Moritz Barsnick's suggestion.

Is there a good way to generate the tone while avoiding floating point 
operations?  If there is then don't bother reviewing this patch and I'll make 
that change once I know better how to do it.

I removed the unrelated changes.  The two parameters, tone_duration and 
tone_frequency, are integers now.  The tone_duration parameter is changed from 
seconds to milliseconds.  I have updated the documentation to reflect that.  I 
moved the tone generation to an initialization function and fill a buffer that 
exists for the duration of the filter instead of needlessly generating the tone 
on the fly.  

Thanks,
Greg

-- 
Greg Rowe
www.shoretel.com

From 41405e90cb2fb41441a6cf29c7a0d14362fd1b1f Mon Sep 17 00:00:00 2001
From: Greg Rowe 
Date: Fri, 7 Oct 2016 13:39:58 -0400
Subject: [PATCH] avfilter/af_silenceremove: add optional tone when silence is
 removed

This commit adds two options to the af_silenceremove filter.  It adds
tone_duration and tone_hz making it possible to insert a tone when
silence is removed.  Tone insertion is disabled by default (by using a
tone_duration of 0.0 seconds).

Signed-off-by: Greg Rowe 
---
 Changelog  |   1 +
 doc/filters.texi   |  11 ++-
 libavfilter/af_silenceremove.c | 161 +++--
 libavfilter/version.h  |   2 +-
 4 files changed, 151 insertions(+), 24 deletions(-)

diff --git a/Changelog b/Changelog
index 0da009c..86e031c 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest 
within each release,
 releases are sorted from youngest to oldest.
 
 version :
+- Added optional tone insertion in af_silenceremove
 - libopenmpt demuxer
 - tee protocol
 - Changed metadata print option to accept general urls
diff --git a/doc/filters.texi b/doc/filters.texi
index 4b2f7bf..e09a303 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3340,7 +3340,8 @@ ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f 
null -
 
 @section silenceremove
 
-Remove silence from the beginning, middle or end of the audio.
+Remove silence from the beginning, middle or end of the audio while
+optionally inserting a tone where silence was removed.
 
 The filter accepts the following options:
 
@@ -3401,6 +3402,14 @@ Default value is @code{rms}.
 @item window
 Set ratio used to calculate size of window for detecting silence.
 Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
+
+@item tone_duration
+Set the duration of the tone inserted in the stream when silence is removed.  
A value of @code{0} disables tone insertion.
+Default value is @code{0.0}.
+
+@item tone_hz
+Set the frequency of the tone inserted in the stream when silence is removed.
+Default value is @code{1000.0}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
index f156d18..07cf428 100644
--- a/libavfilter/af_silenceremove.c
+++ b/libavfilter/af_silenceremove.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2001 Chris Bagwell
  * Copyright (c) 2003 Donnie Smith
  * Copyright (c) 2014 Paul B Mahol
+ * Copyright (c) 2016 Shoretel 
  *
  * This file is part of FFmpeg.
  *
@@ -31,11 +32,20 @@
 #include "internal.h"
 
 enum SilenceMode {
-SILENCE_TRIM,
+SILENCE_TRIM = 0,
 SILENCE_TRIM_FLUSH,
 SILENCE_COPY,
 SILENCE_COPY_FLUSH,
-SILENCE_STOP
+SILENCE_STOP,
+SILENCE_END_MARKER
+};
+
+static const char* SILENCE_MODE_NAMES[] = {
+NULL_IF_CONFIG_SMALL("TRIM"),
+NULL_IF_CONFIG_SMALL("TRIM_FLUSH"),
+NULL_IF_CONFIG_SMALL("COPY"),
+NULL_IF_CONFIG_SMALL("COPY_FLUSH"),
+NULL_IF_CONFIG_SMALL("STOP")
 };
 
 typedef struct SilenceRemoveContext {
@@ -75,6 +85,10 @@ typedef struct SilenceRemoveContext {
 int detection;
 void (*update)(struct SilenceRemoveContext *s, double sample);
 double(*compute)(struct SilenceRemoveContext *s, double sample);
+
+double last_pts_seconds;
+double tone_duration;
+double tone_hz;
 } SilenceRemoveContext;
 
 #define OFFSET(x) offsetof(SilenceRemoveContext, x)
@@ -91,11 +105,51 @@ static const AVOption silenceremove_options[] = {
 {   "peak",  0,0,   AV_OPT_TYPE_CONST,
{.i64=0}, 0,   0, FLAGS, "detection" },
 {   "rms",   0,0,   AV_OPT_TYPE_CONST,
{.i64=1}, 0,   0, FLAGS, "detection" },
 { "window",  NULL, OFFSET(window_ratio),AV_OPT_TYPE_DOUBLE,   
{.dbl=0.02},  0,  10, FLAGS },
-{ NULL }
+{
+.name = "tone_duration",
+.help = "length of tone inserted when silence is detected (0 to 
disable)",
+.offset = OFFSET(tone_duration),
+.type = AV_OPT_TYPE_DOUBLE,
+.default_val = {.dbl=0.0},
+.min = 0.0,
+.max = D

Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-14 Thread Moritz Barsnick
>  enum SilenceMode {
> -SILENCE_TRIM,
> +SILENCE_TRIM = 0,
>  SILENCE_TRIM_FLUSH,
>  SILENCE_COPY,
>  SILENCE_COPY_FLUSH,
> -SILENCE_STOP
> +SILENCE_STOP,
> +SILENCE_END_MARKER
> +};
> +
> +static const char* SILENCE_MODE_NAMES[] = {
> +NULL_IF_CONFIG_SMALL("TRIM"),
> +NULL_IF_CONFIG_SMALL("TRIM_FLUSH"),
> +NULL_IF_CONFIG_SMALL("COPY"),
> +NULL_IF_CONFIG_SMALL("COPY_FLUSH"),
> +NULL_IF_CONFIG_SMALL("STOP")
>  };

This (and related functions) is probably unrelated to the feature
you're adding, and rather a commodity, so I guess it should be in a
separate patch.

And I personally would probably name the frequency option
"tone_frequency" as just that, and not with its unit Hz as "tone_hz",
but that's cosmetic.

Moritz

P.S.: Nice feature for debug.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-13 Thread Michael Niedermayer
On Thu, Oct 13, 2016 at 08:48:11PM +, Greg Rowe wrote:
> The attached patch adds two optional parameters to af_silenceremove for the 
> purpose of inserting a tone in place of where silence was removed.  This 
> alerts the user that silence has been trimmed from the original stream.  The 
> parameters are tone_duration which defaults to 0.0 which disables the feature 
> and tone_hz which allows you to specify the frequency of the tone.
> 
> 
> Thanks,
> 
> Greg
> 
> 
> --
> 
> Greg Rowe
> 
> www.shoretel.com

> From 41405e90cb2fb41441a6cf29c7a0d14362fd1b1f Mon Sep 17 00:00:00 2001
> From: Greg Rowe 
> Date: Fri, 7 Oct 2016 13:39:58 -0400
> Subject: [PATCH] avfilter/af_silenceremove: add optional tone when silence is
>  removed
> 
> This commit adds two options to the af_silenceremove filter.  It adds
> tone_duration and tone_hz making it possible to insert a tone when
> silence is removed.  Tone insertion is disabled by default (by using a
> tone_duration of 0.0 seconds).
> 
> Signed-off-by: Greg Rowe 
> ---
>  Changelog  |   1 +
>  doc/filters.texi   |  11 ++-
>  libavfilter/af_silenceremove.c | 161 
> +++--
>  libavfilter/version.h  |   2 +-
>  4 files changed, 151 insertions(+), 24 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index 0da009c..86e031c 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest 
> within each release,
>  releases are sorted from youngest to oldest.
>  
>  version :
> +- Added optional tone insertion in af_silenceremove
>  - libopenmpt demuxer
>  - tee protocol
>  - Changed metadata print option to accept general urls
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 4b2f7bf..e09a303 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -3340,7 +3340,8 @@ ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f 
> null -
>  
>  @section silenceremove
>  
> -Remove silence from the beginning, middle or end of the audio.
> +Remove silence from the beginning, middle or end of the audio while
> +optionally inserting a tone where silence was removed.
>  
>  The filter accepts the following options:
>  
> @@ -3401,6 +3402,14 @@ Default value is @code{rms}.
>  @item window
>  Set ratio used to calculate size of window for detecting silence.
>  Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
> +
> +@item tone_duration
> +Set the duration of the tone inserted in the stream when silence is removed. 
>  A value of @code{0} disables tone insertion.
> +Default value is @code{0.0}.
> +
> +@item tone_hz
> +Set the frequency of the tone inserted in the stream when silence is removed.
> +Default value is @code{1000.0}.
>  @end table
>  
>  @subsection Examples
> diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
> index f156d18..07cf428 100644
> --- a/libavfilter/af_silenceremove.c
> +++ b/libavfilter/af_silenceremove.c
> @@ -3,6 +3,7 @@
>   * Copyright (c) 2001 Chris Bagwell
>   * Copyright (c) 2003 Donnie Smith
>   * Copyright (c) 2014 Paul B Mahol
> + * Copyright (c) 2016 Shoretel 
>   *
>   * This file is part of FFmpeg.
>   *

> @@ -31,11 +32,20 @@
>  #include "internal.h"
>  
>  enum SilenceMode {
> -SILENCE_TRIM,
> +SILENCE_TRIM = 0,

unrelated change and thus should not be in this patch


>  SILENCE_TRIM_FLUSH,
>  SILENCE_COPY,
>  SILENCE_COPY_FLUSH,
> -SILENCE_STOP
> +SILENCE_STOP,
> +SILENCE_END_MARKER
> +};
> +
> +static const char* SILENCE_MODE_NAMES[] = {
> +NULL_IF_CONFIG_SMALL("TRIM"),
> +NULL_IF_CONFIG_SMALL("TRIM_FLUSH"),
> +NULL_IF_CONFIG_SMALL("COPY"),
> +NULL_IF_CONFIG_SMALL("COPY_FLUSH"),
> +NULL_IF_CONFIG_SMALL("STOP")
>  };
>  
>  typedef struct SilenceRemoveContext {
> @@ -75,6 +85,10 @@ typedef struct SilenceRemoveContext {
>  int detection;
>  void (*update)(struct SilenceRemoveContext *s, double sample);
>  double(*compute)(struct SilenceRemoveContext *s, double sample);
> +
> +double last_pts_seconds;
> +double tone_duration;
> +double tone_hz;
>  } SilenceRemoveContext;
>  
>  #define OFFSET(x) offsetof(SilenceRemoveContext, x)
> @@ -91,11 +105,51 @@ static const AVOption silenceremove_options[] = {
>  {   "peak",  0,0,   AV_OPT_TYPE_CONST,   
>  {.i64=0}, 0,   0, FLAGS, "detection" },
>  {   "rms",   0,0,   AV_OPT_TYPE_CONST,   
>  {.i64=1}, 0,   0, FLAGS, "detection" },
>  { "window",  NULL, OFFSET(window_ratio),AV_OPT_TYPE_DOUBLE,  
>  {.dbl=0.02},  0,  10, FLAGS },
> +{
> +.name = "tone_duration",
> +.help = "length of tone inserted when silence is detected (0 to 
> disable)",
> +.offset = OFFSET(tone_duration),
> +.type = AV_OPT_TYPE_DOUBLE,
> +.default_val = {.dbl=0.0},
> +.min = 0.0,
> +.max = DBL_MAX,

[FFmpeg-devel] [PATCH] avfilter/af_silenceremove: add optional tone when silence is removed

2016-10-13 Thread Greg Rowe
The attached patch adds two optional parameters to af_silenceremove for the 
purpose of inserting a tone in place of where silence was removed.  This alerts 
the user that silence has been trimmed from the original stream.  The 
parameters are tone_duration which defaults to 0.0 which disables the feature 
and tone_hz which allows you to specify the frequency of the tone.


Thanks,

Greg


--

Greg Rowe

www.shoretel.com
From 41405e90cb2fb41441a6cf29c7a0d14362fd1b1f Mon Sep 17 00:00:00 2001
From: Greg Rowe 
Date: Fri, 7 Oct 2016 13:39:58 -0400
Subject: [PATCH] avfilter/af_silenceremove: add optional tone when silence is
 removed

This commit adds two options to the af_silenceremove filter.  It adds
tone_duration and tone_hz making it possible to insert a tone when
silence is removed.  Tone insertion is disabled by default (by using a
tone_duration of 0.0 seconds).

Signed-off-by: Greg Rowe 
---
 Changelog  |   1 +
 doc/filters.texi   |  11 ++-
 libavfilter/af_silenceremove.c | 161 +++--
 libavfilter/version.h  |   2 +-
 4 files changed, 151 insertions(+), 24 deletions(-)

diff --git a/Changelog b/Changelog
index 0da009c..86e031c 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest 
within each release,
 releases are sorted from youngest to oldest.
 
 version :
+- Added optional tone insertion in af_silenceremove
 - libopenmpt demuxer
 - tee protocol
 - Changed metadata print option to accept general urls
diff --git a/doc/filters.texi b/doc/filters.texi
index 4b2f7bf..e09a303 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3340,7 +3340,8 @@ ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f 
null -
 
 @section silenceremove
 
-Remove silence from the beginning, middle or end of the audio.
+Remove silence from the beginning, middle or end of the audio while
+optionally inserting a tone where silence was removed.
 
 The filter accepts the following options:
 
@@ -3401,6 +3402,14 @@ Default value is @code{rms}.
 @item window
 Set ratio used to calculate size of window for detecting silence.
 Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
+
+@item tone_duration
+Set the duration of the tone inserted in the stream when silence is removed.  
A value of @code{0} disables tone insertion.
+Default value is @code{0.0}.
+
+@item tone_hz
+Set the frequency of the tone inserted in the stream when silence is removed.
+Default value is @code{1000.0}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
index f156d18..07cf428 100644
--- a/libavfilter/af_silenceremove.c
+++ b/libavfilter/af_silenceremove.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2001 Chris Bagwell
  * Copyright (c) 2003 Donnie Smith
  * Copyright (c) 2014 Paul B Mahol
+ * Copyright (c) 2016 Shoretel 
  *
  * This file is part of FFmpeg.
  *
@@ -31,11 +32,20 @@
 #include "internal.h"
 
 enum SilenceMode {
-SILENCE_TRIM,
+SILENCE_TRIM = 0,
 SILENCE_TRIM_FLUSH,
 SILENCE_COPY,
 SILENCE_COPY_FLUSH,
-SILENCE_STOP
+SILENCE_STOP,
+SILENCE_END_MARKER
+};
+
+static const char* SILENCE_MODE_NAMES[] = {
+NULL_IF_CONFIG_SMALL("TRIM"),
+NULL_IF_CONFIG_SMALL("TRIM_FLUSH"),
+NULL_IF_CONFIG_SMALL("COPY"),
+NULL_IF_CONFIG_SMALL("COPY_FLUSH"),
+NULL_IF_CONFIG_SMALL("STOP")
 };
 
 typedef struct SilenceRemoveContext {
@@ -75,6 +85,10 @@ typedef struct SilenceRemoveContext {
 int detection;
 void (*update)(struct SilenceRemoveContext *s, double sample);
 double(*compute)(struct SilenceRemoveContext *s, double sample);
+
+double last_pts_seconds;
+double tone_duration;
+double tone_hz;
 } SilenceRemoveContext;
 
 #define OFFSET(x) offsetof(SilenceRemoveContext, x)
@@ -91,11 +105,51 @@ static const AVOption silenceremove_options[] = {
 {   "peak",  0,0,   AV_OPT_TYPE_CONST,
{.i64=0}, 0,   0, FLAGS, "detection" },
 {   "rms",   0,0,   AV_OPT_TYPE_CONST,
{.i64=1}, 0,   0, FLAGS, "detection" },
 { "window",  NULL, OFFSET(window_ratio),AV_OPT_TYPE_DOUBLE,   
{.dbl=0.02},  0,  10, FLAGS },
-{ NULL }
+{
+.name = "tone_duration",
+.help = "length of tone inserted when silence is detected (0 to 
disable)",
+.offset = OFFSET(tone_duration),
+.type = AV_OPT_TYPE_DOUBLE,
+.default_val = {.dbl=0.0},
+.min = 0.0,
+.max = DBL_MAX,
+.flags = FLAGS,
+.unit = "tone",
+},
+{
+.name = "tone_hz",
+.help = "frequency of tone inserted when silence is removed, 1 kHz 
default",
+.offset = OFFSET(tone_hz),
+.type = AV_OPT_TYPE_DOUBLE,
+.default_val = {.dbl=1000.0},
+.min = 0.0,
+.max = DBL_MAX,
+.flags = FLAGS,
+.unit = "tone",
+