node-media-capture
Node.js implementation of the W3C Media Capture and Streams
##Features
Currently supports the following APIs:
- MediaStream
- MediaStreamTrack
- MediaDevices
- MediaRecorder (partially)
- ImageCapture (partially)
###Specs
####Difference from W3C APIs
MediaRecorder
'sondataavailable()
returns node'sBuffer
instead ofArrayBuffer
.ImageCapture
'stakePhoto()
returns node'sBuffer
instead ofBlob
.
###Status
- Currently supports Mac OS X only. (tested on MBP + Yosemite.)
- Currently supports video tracks only. (audio is being implemented.)
MediaRecorder
's recording operations (pause/resume) are not supported.ImageCapture
's settings are not supported.
##Install
Note that only the Mac OS X is supported.
$ git clone git@github.com:kuu/node-media-capture.git
$ cd node-media-capture
$ npm install
##Run
Run the sample app:
$ npm start
Go to http://localhost:8080/ with your browser.
##Usage
import NMC from 'node-media-capture';
let navigator = NMC.navigator,
MediaRecorder = NMC.MediaRecorder,
ImageCapture = NMC.ImageCapture;
navigator.mediaDevices.getUserMedia({video: true})
.then(
(stream) => {
// Video capture
let recorder = new MediaRecorder(stream);
recorder.ondataavailable = (buf) => {
console.log('----- Video captured. size=' + buf.length);
};
// Image capture
let capture = new ImageCapture(stream.getVideoTracks()[0]);
capture.takePhoto().then((buf) => {
console.log('----- Image captured. size=' + buf.length);
});
},
(e) => {
throw e;
}
);
See the specs for the details.