Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8573 closed defect (invalid)

The output pts of audio filter 'atempo' seems to be wrong.

Reported by: elite_jwp Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: atempo
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

At libavfilter/af_atempo.c:1061, the code is as below:

    atempo->dst_buffer->pts = atempo->start_pts +
        av_rescale_q(atempo->nsamples_out,
                     (AVRational){ 1, outlink->sample_rate },
                     outlink->time_base);

According to tempo factor, the number of output samples may be different with that of input samples, but they are equal in time duration.
Generally, inlink->sample_rate is same with outlink->sample_rate. So it seems that the duration of nsamples_out can't be computed like above code. It should take count of tempo factor, and can be fixed like below?

    atempo->dst_buffer->pts = atempo->start_pts +
        av_rescale_q(atempo->nsamples_out,
                     (AVRational){ 1, (int)(outlink->sample_rate/atempo->tempo) },
                     outlink->time_base);

Change History (3)

comment:1 by Elon Musk, 4 years ago

Resolution: invalid
Status: newclosed

No, that is logic failure. Code is correct.
Atempo changes duration of audio so pts must change too.

comment:2 by elite_jwp, 4 years ago

Ok. Thanks.
But here exists a case:
I want to change the playback speed in ffplay.exe. So i used the atempo filter to do it.
With 'AV_SYNC_AUDIO_MASTER' mode in ffplay, video is synchronized to audio.
If only changing the audio tempo, it will cause the pts diffrence too big and unsynchronized between video and audio.
Should i also change the video speed for that purpose?

Last edited 4 years ago by elite_jwp (previous) (diff)

comment:3 by Elon Musk, 4 years ago

Yes, you need to change video pts. Note that bug report site is not for general help around ffmpeg. For more info ask elsewhere.

Note: See TracTickets for help on using tickets.