title: Pipe opencv frames to ffmpeg
body: <p>I am trying to pipe opencv frames to ffmpeg using rawvideo format, which should accept the input as BGRBGRBGR... encoding the frame before piping is not an option.</p>
  
  <pre><code>cv::Mat frame;
  cv::VideoCapture cap("cap.avi");
  
  while(1)
  {
      cap &gt;&gt; frame;
      if(!frame.data) break;
  
      // some processing
  
      cv::Mat array = frame.reshape(0, 1); // to make continuous
      std::string output((char*) array.data, array.total() * array.elemSize());
      std::cout &lt;&lt; output;
  }
  </code></pre>
  
  <p>with command</p>
  
  <pre><code>cap.exe | ffplay -f rawvideo -pixel_format bgr24 -video_size 1920x1080 -framerate 10 -i -
  </code></pre>
  
  <p>gives <a href="http://imgur.com/BoMuq2R" rel="nofollow">this kind of</a> distorted result</p>
  
  <p>I think problem is not related to ffmpeg/ffplay, but something is wrong with my frame to raw conversion</p>
  
  <p>how to convert mat with 3 channels to rawvideo bgr24 format ?</p>