Hello,

When transcoding a movie, using libav, the audio starts drifting when
resampling 44100 to 48000 khz

I saw this piece of code in ffmpeg.c, but I don't really understand how
ffmpeg calculates the delta.
It is based on the state of input and output stream.

Also, I don't know exactly the value of audio_sync_method...

See this:

        double delta = get_sync_ipts(ost) * enc->sample_rate -
ost->sync_opts
                - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2);

.......

int comp= av_clip(delta, -audio_sync_method, audio_sync_method);
                assert(ost->audio_resample);
                if(verbose > 2)
                    fprintf(stderr, "compensating audio timestamp drift:%f
compensation:%d in:%d\n", delta, comp, enc->sample_rate);
//                fprintf(stderr, "drift:%f len:%d opts:%"PRId64"
ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts,
(int64_t)(get_sync_ipts(ost) * enc->sample_rate),
av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2));
                av_resample_compensate(*(struct
AVResampleContext**)ost->resample, comp, enc->sample_rate);
            }

Is there any simple way to calculate delta, for instance by comparing the
number of samples written or read?

Arthur
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to