When using the multi ffmpeg overlay filter, the memory usage becomes excessively high

When stitching four 1080p videos, multi-threaded decoding is used, and a single thread writes to their respective buffersrc filters. During the process, it was observed that memory usage rapidly increases (memory usage remains normal when only decoding is performed, without calling av_buffersrc_write_frame and av_buffersink_get_frame). Additionally, even after calling av_buffersink_get_frame, the memory does not decrease, even when av_frame_unref is invoked. It appears that there is a fixed buffer in the filter chain that is not being cleared. How can this issue be resolved?

The code is at attach.

Read more here: Source link