title: ffmpeg convert stream to jpg buffer without saving do disk
body: <p>I have a webrtc video stream coming from the client to the server.
  I want to convert the stream into jpg images, but not save any image to disk (work from memory only).
  Currently I'm using this command line function (called from node js):</p>
  
  <pre><code>var ops = [
  '-i', '-',
  '-f', 'image2',
  '-vcodec', 'mjpeg',
  '-b:v', '1000k',
  '-q:v', '2',
  '-s', '640x480',
  '-updatefirst', '1',
  '-',
  ];
  
  ffmpeg_process = cp.spawn('ffmpeg', ops);
  
  ffmpeg_process.stdout.on('data', function(chunk) {
  var size = chunk.length
  data += chunk
  if (((chunk[size - 2] &lt;&lt; 8) + chunk[size - 1]) === 65497)  //EOF 
  {
     if (data) 
    {
  lib.addFrame(Buffer(data).toString('base64')) //full jpg data
    }
    data = ''
  }
  };
  </code></pre>
  
  <p>However, some of the output jpg images are corrupt. this is because sometimes the buffer contains only part of a jpg image data.</p>
  
  <p>What are the correct params needed to be passed to ffmpeg for correctly creating the jpg images?</p>