From a8780b9c7132b80cd0f0f3cb99fc34bf38874f34 Mon Sep 17 00:00:00 2001
From: nicolas gaullier <nicolas.gaullier@arkena.com>
Date: Fri, 2 Feb 2018 11:14:47 +0100
Subject: [PATCH 2/4] avfilter/af_silencedetect : fix silence_start accuracy

---
 libavfilter/af_silencedetect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
index 62147fc84a..eb50435ad5 100644
--- a/libavfilter/af_silencedetect.c
+++ b/libavfilter/af_silencedetect.c
@@ -80,7 +80,7 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples,
         if (!s->start[channel]) {
             s->nb_null_samples[channel]++;
             if (s->nb_null_samples[channel] >= nb_samples_notify) {
-                s->start[channel] = insamples->pts - (int64_t)(s->duration / av_q2d(s->time_base) + .5);
+                s->start[channel] = insamples->pts + (int64_t)(((double)current_sample / (s->last_sample_rate * s->channels) - s->duration) / av_q2d(s->time_base) + .5);
                 set_meta(insamples, s->mono ? channel + 1 : 0, "silence_start", av_ts2timestr(s->start[channel], &s->time_base));
                 if (s->mono)
                     av_log(s, AV_LOG_INFO, "channel: %d | ", channel);
-- 
2.15.0

