Started happening with 422dd9404f that introduced multi-threaded
conversions of src->dst (usually RGBA->YUV) format before encoding
the frame with ffmpeg. But the issue itself is not related to
multi-threading, but rather with the fact that AVFrame objects
started to be backed by an AVBuffer object (as that is needed for
threaded swscale to work).
Turns out, if a frame is backed by AVBuffer object, said buffer
might become "non writable" because it got shared (non-1 refcount).
And that happens with some ffmpeg video codecs, particularly PNG one.
Make sure to make the AVFrame objects writable inside
generate_video_frame. This follows official ffmpeg example
(doc/examples/encode_video.c) that explains why that is needed:
"the codec may have kept a reference to the frame in its internal
structures, that makes the frame unwritable. av_frame_make_writable()
checks that and allocates a new buffer for the frame only if necessary"
Pull Request: https://projects.blender.org/blender/blender/pulls/126317