[Libav-user] Synchronising an audio and video streams when muxing

Nuno Santos nuno.santos at imaginando.pt
Sat Dec 11 21:24:27 EET 2021


Yurii,

In the mean time it occurred to me precisely this approach. It seems to be working! :)

Thank you very much for your reply

Best,

--
Nuno Santos

> No dia 11/12/2021, às 18:12, Yurii Monakov <monakov.y at gmail.com> escreveu:
> 
> 
> You can derive your video pts from audio pts by rescaling and call av_interleaved_write_frame. Mixer will do the rest.
> 
> Yurii
> 
> пт, 10 дек. 2021 г. в 12:23, Nuno Santos <nuno.santos at imaginando.pt>:
>> Hi,
>> 
>> I’m generating a visual feed that is reacting to audio. Both audio and video are being generated in real time, each in its own thread.
>> 
>> While the audio generation is always steady, video generation is not precise and can have fluctuations.
>> 
>> While the muxing example provides a good start on how to use ffmpeg for audio and video muxing, it doesn’t cover synchronisation aspects since the video and the audio are generated in the same loop, on demand, without any possible fluctuation.
>> 
>> I’m trying to achieve perfect synchronisation between audio and video but I feel I’m navigating uncharted terrains here.
>> 
>> Some problems that I have identified but don’t have a proper solution at the moment:
>> 
>> - the audio buffer can start having samples sooner than the video buffer of vice-versa. Ideally the first frame of video should match the first frame of audio. 
>> - I’m already rescaling the video pts and dts to adjust the video generation fluctuations but audio is always a fixed value and cannot fluctuate
>> 
>> Are there examples that show how to achieve this? What are the best practices? 
>> 
>> Thank you!
>> 
>> Best regards,
>> 
>> Nuno
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>> 
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
> 
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20211211/80e2e869/attachment.htm>


More information about the Libav-user mailing list