W3C home > Mailing lists > Public > public-media-capture@w3.org > January 2018

[mediacapture-image] Faster MediaStream ImageCapture.takePhoto

From: Michal via GitHub <sysbot+gh@w3.org>
Date: Sun, 14 Jan 2018 17:54:49 +0000
To: public-media-capture@w3.org
Message-ID: <issues.opened-288426493-1515952487-sysbot+gh@w3.org>
developer239 has just created a new issue for https://github.com/w3c/mediacapture-image:

== Faster MediaStream ImageCapture.takePhoto ==
I get MediaStream object from `navigator.mediaDevices.getUserMedia`:

```
navigator.mediaDevices.getUserMedia({
  audio: false,
  video: {
    mandatory: {
      chromeMediaSource: 'desktop',
      chromeMediaSourceId: source.id,
      minWidth: 800,
      maxWidth: 800,
      minHeight: 800,
      maxHeight: 800,
    },
  },
})
.then((stream) => {
```

I am trying to get node Buffer of **every** a still frame using ImageCapture:

```
  const track = stream.getVideoTracks()[0];
  const capturedImage = new ImageCapture(track);

  capturedImage // This takes 200ms for 1000x1000
    .takePhoto()
    .then(blob => {
      toBuffer(blob, function (err, buffer) { // 1.5 ms
        if (err) throw err;
          // TODO: Do some opencv magic with node buffer
      });
    })
    .catch(error => console.error('takePhoto() error:', error));
```

But it takes awfully long to takePhoto. Is it possible to make the process faster? Can I somehow access the `MediaStream` directly as `readable stream` in nodejs?



Please view or discuss this issue at https://github.com/w3c/mediacapture-image/issues/197 using your GitHub account
Received on Sunday, 14 January 2018 17:54:51 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 14 January 2018 17:54:52 UTC