[FFmpeg-cvslog] lavfi/silencedetect: Fix silence_end accuracy
Nicolas Gaullier
git at videolan.org
Thu Mar 29 17:12:25 EEST 2018
ffmpeg | branch: master | Nicolas Gaullier <nicolas.gaullier at arkena.com> | Mon Feb 19 14:16:17 2018 +0100| [5170ab20e1f5278cc024a04e348828e38db3f361] | committer: Paul B Mahol
lavfi/silencedetect: Fix silence_end accuracy
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5170ab20e1f5278cc024a04e348828e38db3f361
---
libavfilter/af_silencedetect.c | 3 ++-
tests/ref/fate/filter-metadata-silencedetect | 12 ++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
index 749c3fbcb7..8973049fe5 100644
--- a/libavfilter/af_silencedetect.c
+++ b/libavfilter/af_silencedetect.c
@@ -92,7 +92,8 @@ static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples,
}
} else {
if (s->start[channel] > INT64_MIN) {
- int64_t end_pts = insamples->pts;
+ int64_t end_pts = insamples->pts + av_rescale_q(current_sample / s->channels,
+ (AVRational){ 1, s->last_sample_rate }, time_base);
int64_t duration_ts = end_pts - s->start[channel];
set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end",
av_ts2timestr(end_pts, &time_base));
diff --git a/tests/ref/fate/filter-metadata-silencedetect b/tests/ref/fate/filter-metadata-silencedetect
index 917b836250..e4be2ffac7 100644
--- a/tests/ref/fate/filter-metadata-silencedetect
+++ b/tests/ref/fate/filter-metadata-silencedetect
@@ -17,7 +17,7 @@ pkt_pts=4800
pkt_pts=5120
pkt_pts=5440
pkt_pts=5760
-pkt_pts=6080|tag:lavfi.silence_end=0.38|tag:lavfi.silence_duration=0.38
+pkt_pts=6080|tag:lavfi.silence_end=0.384813|tag:lavfi.silence_duration=0.384813
pkt_pts=6400
pkt_pts=6720
pkt_pts=7040
@@ -97,7 +97,7 @@ pkt_pts=30400
pkt_pts=30720
pkt_pts=31040
pkt_pts=31360
-pkt_pts=31680|tag:lavfi.silence_end=1.98|tag:lavfi.silence_duration=0.792438
+pkt_pts=31680|tag:lavfi.silence_end=1.99538|tag:lavfi.silence_duration=0.807813
pkt_pts=32000
pkt_pts=32320
pkt_pts=32640
@@ -196,7 +196,7 @@ pkt_pts=62080
pkt_pts=62400
pkt_pts=62720
pkt_pts=63040
-pkt_pts=63360|tag:lavfi.silence_end=3.96|tag:lavfi.silence_duration=1.015
+pkt_pts=63360|tag:lavfi.silence_end=3.97138|tag:lavfi.silence_duration=1.02638
pkt_pts=63680
pkt_pts=64000
pkt_pts=64320
@@ -270,7 +270,7 @@ pkt_pts=85760
pkt_pts=86080
pkt_pts=86400
pkt_pts=86720
-pkt_pts=87040|tag:lavfi.silence_end=5.44|tag:lavfi.silence_duration=0.683375
+pkt_pts=87040|tag:lavfi.silence_end=5.45|tag:lavfi.silence_duration=0.693375
pkt_pts=87360
pkt_pts=87680
pkt_pts=88000
@@ -362,7 +362,7 @@ pkt_pts=115200
pkt_pts=115520
pkt_pts=115840
pkt_pts=116160
-pkt_pts=116480|tag:lavfi.silence_end=7.28|tag:lavfi.silence_duration=1.00681
+pkt_pts=116480|tag:lavfi.silence_end=7.28569|tag:lavfi.silence_duration=1.0125
pkt_pts=116800
pkt_pts=117120
pkt_pts=117440
@@ -452,7 +452,7 @@ pkt_pts=144000
pkt_pts=144320
pkt_pts=144640
pkt_pts=144960
-pkt_pts=145280|tag:lavfi.silence_end=9.08|tag:lavfi.silence_duration=0.828937
+pkt_pts=145280|tag:lavfi.silence_end=9.08156|tag:lavfi.silence_duration=0.8305
pkt_pts=145600
pkt_pts=145920
pkt_pts=146240
More information about the ffmpeg-cvslog
mailing list