[FFmpeg-user] Unable to sync audio and video

Nicolas George george at nsup.org
Wed Feb 17 13:44:10 EET 2021


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?

> 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, 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.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210217/08dc26db/attachment.sig>


More information about the ffmpeg-user mailing list