[FFmpeg-devel] [PATCH] lavfi/afade: fix cur_sample computation

Stefano Sabatini stefasab at gmail.com
Tue Oct 21 11:47:19 CEST 2014


Use the correct timebase conversion.
---
 libavfilter/af_afade.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
index fbf9802..35b2a84 100644
--- a/libavfilter/af_afade.c
+++ b/libavfilter/af_afade.c
@@ -221,6 +221,8 @@ static int config_input(AVFilterLink *inlink)
     if (s->start_time)
         s->start_sample = av_rescale(s->start_time, inlink->sample_rate, AV_TIME_BASE);
 
+    av_log(s, AV_LOG_DEBUG, "nb_samples=%d start_sample=%d type=%d\n", s->nb_samples, s->start_sample, s->type);
+
     return 0;
 }
 
@@ -230,7 +232,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     AVFilterLink *outlink   = inlink->dst->outputs[0];
     int nb_samples          = buf->nb_samples;
     AVFrame *out_buf;
-    int64_t cur_sample = av_rescale_q(buf->pts, (AVRational){1, outlink->sample_rate}, outlink->time_base);
+    int64_t cur_sample = av_rescale_q(buf->pts, inlink->time_base, (AVRational){1, inlink->sample_rate});
 
     if ((!s->type && (s->start_sample + s->nb_samples < cur_sample)) ||
         ( s->type && (cur_sample + s->nb_samples < s->start_sample)))
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list