[Libav-user] Multithreaded Asynchronous Encoding/Muxing

Michael Armes michael.armes at gmail.com
Wed Feb 27 19:05:05 EET 2019


I can only respond to question (1), and the answer is yes, but you must
define your own lock manager. See
https://stackoverflow.com/questions/13888915/thread-safety-of-libav-ffmpeg
for more details. There are a few particular methods that have thread
safety concerns. IIRC, writing frames is one. Opening a codec is also not
thread safe:
https://stackoverflow.com/questions/15366441/ffmpeg-which-functions-are-multithreading-safe

HTH,
Michael

On Wed, Feb 27, 2019 at 5:55 AM BIGLER Don (Framatome) <
don.bigler at framatome.com> wrote:

> All,
>
>
>
> I am writing an application that displays, encodes, and muxes live video
> using libav as the backend.  The audio and video encoding occurs
> asynchronously in the background, each in its own thread, such that the
> encoded packets arrive to the av_interleaved_write_frame() function call at
> different times.  H.264 video encoding by itself works fine.  However when
> I add audio, the audio is out of sync from the video even though the audio
> and video pts are in sync (from avdevice using the matroska muxer).  The
> cause of the problem is not clear to me.  Specifically, here are my
> questions:
>
>
>
> 1.     Can the av_interleaved_write_frame() function handle multithreaded
> asynchronous calls for audio and video streams?
>
> 2.     The transcoding example uses a filter graph using buffer/abuffer
> filters.  My current implementation does not use the buffer/abuffer filters
> because I am not applying any filters before encoding.  Are they required
> for my situation?
>
> 3.     The encoding happens randomly within the stream such that the
> first pts received by the muxer is not zero.  Is this required?
>
>
>
> I will greatly appreciate any assistance!
>
>
>
> Regards,
>
> Don Bigler
>
>
> _______________________________________________
> 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: <http://ffmpeg.org/pipermail/libav-user/attachments/20190227/ae03a57b/attachment.html>


More information about the Libav-user mailing list