title: Save bitmap to video (libavcodec ffmpeg)
body: <p>I'd like to convert a HBitmap to a video stream using libavcodec. 
  I get my HBitmap using:</p>
  
  <pre><code>HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight);
  SelectObject(hCaptureDC,hCaptureBitmap); 
  BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY);
  </code></pre>
  
  <p>And I'd like to convert it to YUV (which is required by the codec i'm using). For that I use:</p>
  
  <pre><code>SwsContext *fooContext = sws_getContext(c-&gt;width,c-&gt;height,PIX_FMT_BGR32,   c-&gt;width,c-&gt;height,PIX_FMT_YUV420P,SWS_FAST_BILINEAR,NULL,NULL,NULL);
  
  uint8_t *movie_dib_bits = reinterpret_cast&lt;uint8_t *&gt;(bm.bmBits) + bm.bmWidthBytes * (bm.bmHeight - 1);
  
  int dibrowbytes = -bm.bmWidthBytes;
  
  uint8_t* data_out[1];
  int stride_out[1];
  data_out[0] = movie_dib_bits;
  stride_out[0] = dibrowbytes;
  
  sws_scale(fooContext,data_out,stride_out,0,c-&gt;height,picture-&gt;data,picture-&gt;linesize);  
  </code></pre>
  
  <p>But this is not working at all... Any idea why ? Or how could I do it differently ?</p>
  
  <p>Thank you !</p>