From 0ef82bfb0116ecf1d3b577e63cefabe84fdc407f Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Fri, 1 May 2026 10:18:46 -0400 Subject: [PATCH] Resolve #2247 --- av/codec/context.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/av/codec/context.py b/av/codec/context.py index 0e8692d80..43d39c0ed 100644 --- a/av/codec/context.py +++ b/av/codec/context.py @@ -462,6 +462,14 @@ def decode(self, packet: Packet | None = None): you do not want the library to automatically re-order frames for you (if they are encoded with a codec that has B-frames). + .. warning:: + + This method is **not thread-safe**. Calling :meth:`decode` concurrently + from multiple threads on the same :class:`CodecContext` will corrupt + internal FFmpeg state and likely cause a crash (segfault). FFmpeg 8.1 + enforces this more strictly than earlier releases. If you need to decode + from multiple threads, give each thread its own :class:`CodecContext`. + """ if not self.codec.ptr: raise ValueError("cannot decode unknown codec")