<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.Stylwiadomocie-mail17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=PL link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hello,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I am trying to transmux (remux?) from raw h264 to mp4. My input is in a stream, output goes to a file. Everything works, but I’ve noticed that if I repeat my function multiple times, allocation of memory grows and it is not entirely released back.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>I was able to find first function which is causing me this problems and it is avformat_find_stream_info. I looked for it in Internet and I saw that there is a one expected leak of size 24 bytes, but in my tests it goes way over it. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Here is an example code, stripped to reproduce the leak:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>extern</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"C"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:gray'>#include</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'><libavutil/timestamp.h></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:gray'>#include</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'><libavformat/avformat.h></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:gray'>#include</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'><iostream></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:gray'>#include</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'><fstream></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>ReadFunction</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>void</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>* </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>opaque</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>uint8_t</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>* </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buf</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buf_size</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>) </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>noexcept</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>auto</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>& </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = *</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>reinterpret_cast</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>istream</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>*>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>opaque</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>read</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>reinterpret_cast</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>char</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>*>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buf</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>), </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buf_size</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>good</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>())<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>gcount</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>else</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>eof</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>())<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EOF</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>else</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EXTERNAL</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int64_t</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>SeekFunction</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>void</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>* </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>opaque</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int64_t</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>offset</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>whence</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>) </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>noexcept</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>auto</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>& </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = *</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>reinterpret_cast</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>istream</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>*>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>opaque</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>switch</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>whence</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>case</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVSEEK_SIZE</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EXTERNAL</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>case</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>SEEK_SET</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>seekg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>offset</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>ios_base</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>beg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>good</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>() ? (</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int64_t</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>tellg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>() : </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EXTERNAL</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>case</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>SEEK_CUR</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>seekg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>offset</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>ios_base</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cur</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>good</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>() ? (</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int64_t</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>tellg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>() : </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EXTERNAL</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>case</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>SEEK_END</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>seekg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>offset</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>ios_base</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>end</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>good</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>() ? (</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int64_t</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>me</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>tellg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>() : </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EXTERNAL</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>default</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>return</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVERROR_EXTERNAL</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>void</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>Transmux</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>istream</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>& </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>const</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>string</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>& </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>output_file_path</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>) </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>noexcept</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>AVFormatContext</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>* </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>avformat_alloc_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (!</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Could not allocate input context.\n"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>-></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>flags</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>AVFMT_FLAG_CUSTOM_IO</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>unsigned</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>char</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>* </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buffer</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>reinterpret_cast</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>unsigned</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>char</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>*>(av_malloc(8192));<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (!</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buffer</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Could not allocate buffer.\n"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>AVIOContext</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>* </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>io_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>avio_alloc_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buffer</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, 8192, 0, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>reinterpret_cast</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>void</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>*>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>static_cast</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>istream</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>*>(&</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)), &</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>ReadFunction</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>nullptr</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, &</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>SeekFunction</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (!</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>io_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Could not allocate io context.\n"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>-></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>pb</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>io_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>avformat_open_input</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(&</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>""</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>NULL</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>NULL</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>) < 0)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Could not open input.\n "</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>avformat_find_stream_info</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A000A0'>NULL</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>) < 0) </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:green'>// Comment out this and there is no leak.</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Could not find stream info.\n"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>av_freep</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(&</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>io_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>-></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>buffer</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>avio_context_free</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(&</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>io_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>avformat_close_input</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(&</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>input_context</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>main</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>ifstream</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"E:\\Encoder\\libx264_movie.dat"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>ios</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>binary</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>if</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>fail</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>())<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Could not open file.\n "</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>for</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> (</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>Index</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> = 0; </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>Index</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> < 1000; </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>Index</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>++) </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:green'>// More iterations means more memory allocated but it does not grow linearly. </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>clear</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>seekg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(0, </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>ios_base</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>beg</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>Transmux</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>(</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>, </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"E:\\Encoder\\output.mp4"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cout</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'><<</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#A31515'>"Finished.\n"</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>stream</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>.</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:#880000'>close</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>int</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>n</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:blue'>std</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>::</span><i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>cin</span></i><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:teal'>>></span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'> </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:navy'>n</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>If I comment out avformat_find_stream_info() the amount of allocated memory at the end of program is always the same regardless of number of times I repeat Transmux() function.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>If I leave avformat_find_stream_info() then not all memory is released back. The more times I repeat Transmux() the more memory is left allocated. I do not use Linux and Valgrind, I am not<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Experienced enough to do so. I am developing under Windows with libraries distributed with ffmpeg 4.0.0. I know that my testing for leak is very crude but it definitely show some pattern.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Take a look:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Iterations Memory (KB)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>1 2848<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>10 3708<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>100 4040<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>200 4040<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>500 4596<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>1000 5588<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Am I not freeing something? <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>One way of dealing with it (as a workaround) would be to reuse input_context and io_context without allocating/freeing it but I don’t know if this is possible?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks for any help.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>