title: Faster MediaStream ImageCapture (read media stream as buffer in nodejs)
body: <p><strong>Edit:</strong> I need to do this <strong>live</strong>. I can't wait until the stream ends.</p>
  
  <p>I get <code>MediaStream</code> object from electron's <code>desktopCapturer</code>:</p>
  
  <pre><code>navigator.mediaDevices.getUserMedia({
    audio: false,
    video: {
      mandatory: {
        chromeMediaSource: 'desktop',
        chromeMediaSourceId: source.id,
        minWidth: 800,
        maxWidth: 800,
        minHeight: 800,
        maxHeight: 800,
      },
    },
  })
  .then((stream) =&gt; {
  </code></pre>
  
  <p>I am trying to get node <code>Buffer</code> of a still frame using <code>ImageCapture</code>:</p>
  
  <pre><code>  const track = stream.getVideoTracks()[0];
    const capturedImage = new ImageCapture(track);
  
    capturedImage // This takes 200ms for 1000x1000
      .takePhoto()
      .then(blob =&gt; {
        toBuffer(blob, function (err, buffer) { // 1.5 ms
          if (err) throw err;
            // TODO: Do some opencv magic with node buffer
        });
      })
      .catch(error =&gt; console.error('takePhoto() error:', error));
  </code></pre>
  
  <p>But it takes awfully long to <code>takePhoto</code>. Is it possible to make the process faster? Can I somehow access the <code>MediaStream</code> directly in <code>nodejs</code>?</p>