<div dir="ltr"><div><font face="monospace, monospace">Hi Wodzu.<br></font></div><div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">From the ffmeg docs about  avformat_find_stream_info():</font></div><div><font face="monospace, monospace">  - <span style="color:rgb(0,0,0)">Read packets of a media file to get stream information.</span></font></div><div><font face="monospace, monospace">  - <span style="color:rgb(0,0,0)">The logical file position is not changed by this function; examined packets may be buffered for later processing.</span></font></div><div><font face="monospace, monospace"><font color="#000000"><br></font></font></div><div><font face="monospace, monospace"><span style="color:rgb(0,0,0)">* Read packets of a media file to get stream information.</span></font></div><div><font face="monospace, monospace">I can see you are using a cusmom io_context, maybe the leak is there.<br></font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">* <span style="color:rgb(0,0,0)">The logical file position is not changed by this function; examined packets may be buffered for later processing.</span></font></div><div><font face="monospace, monospace"><span style="color:rgb(0,0,0)">I haven't checked, but the expected thing for </span><span style="color:rgb(0,0,0);white-space:pre-wrap">avformat_close_input() would be to correctly release the memory of the buffered packets, even if not read.</span></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Hope this is helpful.<br></font></div></div></div></div>