title: how to fill AvFrame pixel by pixel
body: <p>i try to encode opengl output to a mp4 file using ffmpeg but when i want to simply fill AvFrame with pixel colors with this code snippet :</p>
  <pre><code>for (y = 0; y &lt; c-&gt;height; y++) {
  for (x = 0; x &lt; c-&gt;width; x++) {
      int offset = 3 * (x + y * c-&gt;width);
  
      if (x &gt; 2* c-&gt;width / 3 &amp;&amp; x &lt;c-&gt;width )
      {
          frame-&gt;data[0][offset + 0] = 0; // B
          frame-&gt;data[0][offset + 1] = 0; // G
          frame-&gt;data[0][offset + 2] = 255; // R
      } 
      else if(x &lt; 2 * c-&gt;width / 3 &amp;&amp; x &gt; c-&gt;width / 3) {
          frame-&gt;data[0][offset + 0] = 0; // B
          frame-&gt;data[0][offset + 1] = 255; // G
          frame-&gt;data[0][offset + 2] = 0; // R
      }
      else {
          frame-&gt;data[0][offset + 0] = 255; // B
          frame-&gt;data[0][offset + 1] = 0; // G
          frame-&gt;data[0][offset + 2] = 0; // R
      }
  }
  </code></pre>
  <p>then i have this video output :</p>
  <p><a href="https://i.stack.imgur.com/jm1lP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jm1lP.png" alt="enter image description here" /></a></p>
  <p>and i had this options for ffmpeg :</p>
  <p><strong>codec: libx264rgb</strong>
  &amp; <strong>pix_fmt : AV_PIX_FMT_BGR24</strong></p>
  <p>in fact i expect something like this video output :</p>
  <p><a href="https://i.stack.imgur.com/MwCaN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MwCaN.png" alt="enter image description here" /></a></p>
  <p>i'm also new in ffmpeg and i realy dont know advanced stuffs about video encoding ,so anybody knows what is problem?</p>