[Libav-user] FFmpeg thread safety

J Decker d3ck0r at gmail.com
Tue Aug 19 10:09:44 CEST 2014


On Mon, Aug 18, 2014 at 2:30 PM, wm4 <nfxjfg at googlemail.com> wrote:

> All functions that are specific to a certain context (like
> AVCodecContext) are by default not thread-safe. Of course using
> different contexts at the same time from different threads should be
> perfectly fine.
>
> However, many codecs use some global data that is usually constant, but
> needs to be initialized once. That's why av_lockmgr_register() exists.
> It's a very messy way to allocate mutexes that are supposed to
> coordinate this initialization.
>
>
So if I have lots of videos, and want to play multiple videos at the same
time, using separate contexts for each is OK? Or is it not OK because the
codecs use globals?
Or I have to put critical sections around every call to the library suite?
A semi-off-topic question?  Why does avcodec-56 allocate so many threads?
 Why does it need any more threads than the thread I call a decode with?

In the example code, decoding audio and video in separate threads didn't
require locks?  What if I have a thread per video and play 32 on the screen
at once?


> However, at least FFmpeg (not Libav) doesn't require this anymore, if
> you have compiled ffmpeg with threading. It may even be safer not to
> use the lock manager stuff, because then you avoid library-safety
> issues.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140819/c97a4320/attachment.html>


More information about the Libav-user mailing list