[Libav-user] FFmpeg thread safety
nfxjfg at googlemail.com
Mon Aug 18 23:30:07 CEST 2014
On Mon, 18 Aug 2014 23:22:02 +0200
Patrick Dehne <patrick at mysonicweb.de> wrote:
> Am 18.08.2014 um 23:10 schrieb wm4 <nfxjfg at googlemail.com>:
> > On Mon, 11 Aug 2014 12:39:02 +0200
> > Ole Andre Birkedal <o.birkedal at sportradar.com> wrote:
> >> Hi.
> >> I'm currently developing a multithreaded C++ program using std::thread.
> >> Recently I have been having some crashing issues and it all seems to
> >> related non-thread safety of some function in the FFmpeg API.
> >> Does there exist an exhausting list of all the function that are not
> >> thread safe?
> > All of them.
> You may want to take a look at the documentation of av_lockmgr_register.
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
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.
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
More information about the Libav-user