diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c index e21b3e4a04..e05c0a179d 100644 --- a/libavfilter/af_aresample.c +++ b/libavfilter/af_aresample.c @@ -230,10 +230,15 @@ static int request_frame(AVFilterLink *outlink) if (ret == AVERROR_EOF) { AVFrame *outsamplesref; int n_out = 4096; + int64_t pts; outsamplesref = ff_get_audio_buffer(outlink, n_out); if (!outsamplesref) return AVERROR(ENOMEM); + + pts = swr_next_pts(aresample->swr, INT64_MIN); + pts = ROUNDED_DIV(pts, inlink->sample_rate); + n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out, 0, 0); if (n_out <= 0) { av_frame_free(&outsamplesref); @@ -242,14 +247,8 @@ static int request_frame(AVFilterLink *outlink) outsamplesref->sample_rate = outlink->sample_rate; outsamplesref->nb_samples = n_out; -#if 0 - outsamplesref->pts = aresample->next_pts; - if(aresample->next_pts != AV_NOPTS_VALUE) - aresample->next_pts += av_rescale_q(n_out, (AVRational){1 ,outlink->sample_rate}, outlink->time_base); -#else - outsamplesref->pts = swr_next_pts(aresample->swr, INT64_MIN); - outsamplesref->pts = ROUNDED_DIV(outsamplesref->pts, inlink->sample_rate); -#endif + + outsamplesref->pts = pts; return ff_filter_frame(outlink, outsamplesref); }