On Fri, Dec 14, 2012 at 11:38 AM, Dominic Laflamme <span dir="ltr"><<a href="mailto:flamz3d@gmail.com" target="_blank">flamz3d@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello,<div>I am attempting to sequentially fetch frames from a movie encoded with libx264. I am using a typical av_read_frame / av_decode_video2 loop (found in most demos out there) to fetch each frames. Like this:</div>
<div>

<br></div><div><div><font face="courier new, monospace">int nbFrames = 0;</font></div><div><font face="courier new, monospace">while ( av_read_frame () >= 0 )</font></div><div><font face="courier new, monospace">{</font></div>


<div><font face="courier new, monospace"><span style="white-space:pre-wrap">      </span>av_decode_video2(&frameFinished);</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">   </span>if ( frameFinished )</font></div>


<div><font face="courier new, monospace"><span style="white-space:pre-wrap">      </span>{</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">               </span>nbFrames++;</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">     </span>}</font></div>


<div><font face="courier new, monospace">}</font></div></div><div><font face="courier new, monospace"><br></font></div><div>Now, my video file has 1000 frames, but after the loop runs, nbFrames only got incremented to 994.</div>

</blockquote><div><br></div><div>Hi Dominic,</div><div>Your loop stops when av_read_frame() returns an error such as EOF.  There may still be decoded frames in memory.  To get those frames out, pass an empty AVPacket (size = 0, data = NULL) into av_decode_video2() until frameFinished returns 0.</div>

<div><br></div></div>