lavfi/silencedetect: Fix silence_end accuracy

This commit is contained in:
Nicolas Gaullier 2018-02-19 14:16:17 +01:00 committed by Paul B Mahol
parent 56b2731aae
commit 5170ab20e1
2 changed files with 8 additions and 7 deletions

View File

@ -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));

View File

@ -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