[Libav-user] Effects of passing contexts (format, codec) between threads

Strahinja Radman dr.strashni at gmail.com
Thu Aug 18 10:11:30 EEST 2022


> > av_read_frame() is not thread safe, it can only be read from one thread.
> 
>  Does it have to be the same thread all the time? In my program, threads change, but it is always one thread at a time, e.g. no simultaneous access. I was wondering if it is error on my part of ffmpeg uses thread local storage and I need to keep it in one thread.
> 

If your threads are reading one at a time then there is no need for them. With threads you want parallelism not sequential access so to me it doesnt make too much sense to have it moved around. It would be best if you can implement thread safe queue. Then one thread simply writes to the queue and others are reading. 

Kind regards,
Strahinja


More information about the Libav-user mailing list