[FFmpeg-user] Unable to sync audio and video

Livio Tenze ltenze at gmail.com
Wed Feb 17 14:30:35 EET 2021


Hi

On Wed, Feb 17, 2021 at 12:44 PM Nicolas George <george at nsup.org> wrote:

> Livio Tenze (12021-02-17):
> > > That should work, provided you checked that your timestamps relate to
> > > the same origin. If some timestamps relate to the system boot and some
> > > to 1970-01-01, you will get a desync.
> >
> > The timestamp I am currently using is related to the pts obtained from
> the
> > AVPacket packets: I use the first PTS packet as reference. Is it a right
> > approach for syncing?
>
> It is the only right approach. But you have not answered the question:
> have you checked that the timestamps of both streams are relative to the
> same origin?
>

No, it is not, because the audio and the video streams come from two
different sources: one webcam and an external microphone. The starting PTS
values are different for two audio and video sources. How should I  get the
same origin with this configuration? Please suggest how to treat this case.

>
> > I haven't found info about this issue: does the av_read_frame call return
> > always the latest acquired packet or does it return a buffered packet? I
> > haven't found this info. The question is related to real-time
> acquisition.
>
> av_read_frame() will not skip packets. A device driver may skip data,
> but you should try to avoid it at all costs.
>

Ok!

>
> > Ok, thank you for this suggestion. Do you suggest to use one thread for
> > every source and one thread for encoding? Is it a good approach in your
> > opinion?
>
> For devices, running each in its own thread is probably the most
> reliable solution. At least until we have a proper event loop.
>

Ok!

Thanks again!
Livius


More information about the ffmpeg-user mailing list