[FFmpeg-devel] [PATCH] avfilter/af_atempo: offset all output timestamps by same amount of first input timestamp

Pavel Koshevoy pkoshevoy at gmail.com
Mon May 6 16:32:15 EEST 2019


On Mon, May 6, 2019, 07:28 Pavel Koshevoy <pkoshevoy at gmail.com> wrote:

>
>
> On Mon, May 6, 2019, 06:42 Paul B Mahol <onemda at gmail.com> wrote:
>
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>> Makes ffplay display correct timestamps when seeking.
>> ---
>>  libavfilter/af_atempo.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
>> index bfdad7d76b..6a23d59641 100644
>> --- a/libavfilter/af_atempo.c
>> +++ b/libavfilter/af_atempo.c
>> @@ -103,6 +103,9 @@ typedef struct ATempoContext {
>>      // 1: output sample position
>>      int64_t position[2];
>>
>> +    // first input timestamp, all other timestamps are offset by this one
>> +    int64_t start_pts;
>> +
>>      // sample format:
>>      enum AVSampleFormat format;
>>
>> @@ -1055,6 +1058,7 @@ static int config_props(AVFilterLink *inlink)
>>      enum AVSampleFormat format = inlink->format;
>>      int sample_rate = (int)inlink->sample_rate;
>>
>> +    atempo->start_pts = AV_NOPTS_VALUE;
>>      return yae_reset(atempo, format, sample_rate, inlink->channels);
>>  }
>>
>> @@ -1068,7 +1072,7 @@ static int push_samples(ATempoContext *atempo,
>>      atempo->dst_buffer->nb_samples  = n_out;
>>
>>      // adjust the PTS:
>> -    atempo->dst_buffer->pts =
>> +    atempo->dst_buffer->pts = atempo->start_pts +
>>          av_rescale_q(atempo->nsamples_out,
>>                       (AVRational){ 1, outlink->sample_rate },
>>                       outlink->time_base);
>> @@ -1097,6 +1101,8 @@ static int filter_frame(AVFilterLink *inlink,
>> AVFrame *src_buffer)
>>      const uint8_t *src = src_buffer->data[0];
>>      const uint8_t *src_end = src + n_in * atempo->stride;
>>
>> +    if (atempo->start_pts == AV_NOPTS_VALUE)
>> +        atempo->start_pts = src_buffer->pts;
>>      while (src < src_end) {
>>          if (!atempo->dst_buffer) {
>>              atempo->dst_buffer = ff_get_audio_buffer(outlink, n_out);
>>
>
>
> Maybe ok.  I am not sure how this would interact with seeking, have you
> tried that?  I can check after work tomorrow, I don't think I can do it
> today as I will be out all evening.
>
> Thank you,
>     Pavel.
>



The commit message answered my question, sorry.  LGTM since you've checked
seeking.

Thank you,
    Pavel.

>
>


More information about the ffmpeg-devel mailing list