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

Strahinja Radman dr.strashni at gmail.com
Thu Aug 18 05:41:56 EEST 2022

> On 18. 8. 2022., at 00:55, Olzhas Zhumabek <anonymous.from.applecity at gmail.com> wrote:
> Hi,
> Recently when utilizing ffmpeg to decode av1 codec video, I started seeing weird errors when transitioning from single threaded implementation to multi threaded one. av_read_frame started failing, because the context got its priv_data set to NULL (there were no lines except thread initialization between the line I observed NULL on and the line where it was non-NULL). Does ffmpeg somehow differentiate between which thread it is run on and what can I do to preserve correctness of my program?
> _______________________________________________
> 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”.


av_read_frame() is not thread safe, it can only be read from one thread. You can then read with one thread and make multiple threads per stream to process the data. 

Kind regards,

More information about the Libav-user mailing list