title: Why do we need a buffer while converting AVFrame from one format to another?
body: <p>I am referring to <a href="https://github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial01.c" rel="nofollow">this</a> source code . The code snippets provided here are from lines (114-138) in the code . This is using the ffmpeg library . Can anyone explain why is the following code required in the program ?  </p>
  
  <pre><code>// Determine required buffer size and allocate buffer
  numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx-&gt;width,
                pCodecCtx-&gt;height);
  buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t)); 
  </code></pre>
  
  <p>In a sense I understand that the following function is associating the destination frame to the buffer . But what is the necessity ?  </p>
  
  <pre><code>avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24, pCodecCtx-&gt;width, pCodecCtx-&gt;height);  
  </code></pre>
  
  <p>PS : I tried removing the buffer and compiling the program . It got compiled . But it is showing the following run time error .  </p>
  
  <blockquote>
    <p>[swscaler @ 0xa06d0a0] bad dst image pointers<br>
    Segmentation fault (core dumped)  </p>
  </blockquote>