# RecordRTC
**Repository Path**: projectsweb/RecordRTC
## Basic Information
- **Project Name**: RecordRTC
- **Description**: WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
- **Primary Language**: JavaScript
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-12-15
- **Last Updated**: 2021-11-02
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# RecordRTC: WebRTC JavaScript Library for Audio+Video+Screen Recording
# Demo: https://www.webrtc-experiment.com/RecordRTC/
[RecordRTC Documentation](https://RecordRTC.org/) / [RecordRTC Wiki Pages](https://github.com/muaz-khan/RecordRTC/wiki) / [RecordRTC Demo](https://www.webrtc-experiment.com/RecordRTC/) / [WebRTC Experiments](https://www.webrtc-experiment.com/)
[](https://npmjs.org/package/recordrtc) [](https://npmjs.org/package/recordrtc) [](https://travis-ci.org/muaz-khan/RecordRTC)
> [RecordRTC](https://www.webrtc-experiment.com/RecordRTC/) is a JavaScript-based media-recording library for modern web-browsers (supporting WebRTC getUserMedia API). It is optimized for different devices and browsers to bring all client-side (pluginfree) recording solutions in single place.
# Check all releases:
* https://github.com/muaz-khan/RecordRTC/releases
Please check [dev](https://github.com/muaz-khan/RecordRTC/tree/master/dev) directory for development files.
1. [RecordRTC API Reference](https://RecordRTC.org/RecordRTC.html)
2. [MediaStreamRecorder API Reference](https://RecordRTC.org/MediaStreamRecorder.html)
3. [StereoAudioRecorder API Reference](https://RecordRTC.org/StereoAudioRecorder.html)
4. [WhammyRecorder API Reference](https://RecordRTC.org/WhammyRecorder.html)
5. [Whammy API Reference](https://RecordRTC.org/Whammy.html)
6. [CanvasRecorder API Reference](https://RecordRTC.org/CanvasRecorder.html)
7. [MultiStreamRecorder API Reference](https://RecordRTC.org/MultiStreamRecorder.html)
8. [MRecordRTC API Reference](https://RecordRTC.org/MRecordRTC.html)
9. [RecordRTCPromisesHandler API Reference](https://RecordRTC.org/RecordRTCPromisesHandler.html)
10. [GifRecorder API Reference](https://RecordRTC.org/GifRecorder.html)
11. [Global API Reference](https://RecordRTC.org/global.html)
12 [RecordRTC and Upload to PHP Server](http://www.muazkhan.com/2017/08/recordrtc-and-upload-to-php-server.html)
## Browsers Support:
| Browser | Support | Features |
| ------------- |-------------|-------------|
| Firefox | [Stable](http://www.mozilla.org/en-US/firefox/new/) / [Aurora](http://www.mozilla.org/en-US/firefox/aurora/) / [Nightly](http://nightly.mozilla.org/) | Audio+Video (Both local/remote) |
| Google Chrome | [Stable](https://www.google.com/intl/en_uk/chrome/browser/) / [Canary](https://www.google.com/intl/en/chrome/browser/canary.html) / [Beta](https://www.google.com/intl/en/chrome/browser/beta.html) / [Dev](https://www.google.com/intl/en/chrome/browser/index.html?extra=devchannel#eula) | Audio+Video (Both local/remote) |
| Opera | [Stable](http://www.opera.com/) / [NEXT](http://www.opera.com/computer/next) | Audio+Video (Both local/remote) |
| Android | [Chrome](https://play.google.com/store/apps/details?id=com.chrome.beta&hl=en) / [Firefox](https://play.google.com/store/apps/details?id=org.mozilla.firefox) / [Opera](https://play.google.com/store/apps/details?id=com.opera.browser) | Audio+Video (Both local/remote) |
| Microsoft Edge | [Normal Build](https://www.microsoft.com/en-us/windows/microsoft-edge) | **Only Audio** - No Video - No Canvas - No Screen |
| Safari 11 | preview/beta (OSX/iOS11) | [Only StereoAudioRecorder](https://www.webrtc-experiment.com/RecordRTC/simple-demos/audio-recording.html) - No Video - No Canvas - No Screen |
## Frameworks
1. Angular2 - [check article](https://medium.com/@SumanthShankar/integrate-recordrtc-with-angular-2-typescript-942c9c4ca93f#.7x5yf2nr5) and [demo github repository](https://github.com/ShankarSumanth/Angular2-RecordRTC) - via [#186](https://github.com/muaz-khan/RecordRTC/issues/186)
2. React.js - [check this article](http://suzannewang.com/recordrtc/) and [demo github repository](https://github.com/szwang/recordrtc-react)
3. Video.js - [check this github repository](https://github.com/collab-project/videojs-record)
4. meteor - [check an old github repository](https://github.com/launchbricklabs/recordrtc-meteor-demo)
> Want to add more? Please make a pull-request to update [`README.md`](https://github.com/muaz-khan/RecordRTC/blob/master/README.md)
## Tests?
* https://travis-ci.org/muaz-khan/RecordRTC
Tests source code:
* https://github.com/muaz-khan/RecordRTC/tree/master/test
## Free?
It is MIT Licenced, which means that you can use it in any commercial/non-commercial product, free of cost.
## RecordRTC Containers Format
> RecordRTC supports vp9, vp8, h264, mkv, opus/vorbis, and pcm (mono/stereo).
#### vp9
```javascript
var options = {
recorderType: MediaStreamRecorder,
mimeType: 'video/webm\;codecs=vp9'
};
var recordRTC = RecordRTC(stream, options);
```
#### vp8
```javascript
var options = {
recorderType: MediaStreamRecorder,
mimeType: 'video/webm\;codecs=vp8'
};
var recordRTC = RecordRTC(stream, options);
```
#### h264
```javascript
var options = {
recorderType: MediaStreamRecorder,
mimeType: 'video/webm\;codecs=h264'
};
var recordRTC = RecordRTC(stream, options);
```
#### pcm
```javascript
var options = {
recorderType: StereoAudioRecorder,
mimeType: 'audio/wav'
};
var recordRTC = RecordRTC(stream, options);
```
#### opus
```javascript
var options = {
recorderType: MediaStreamRecorder,
mimeType: 'audio/webm' // Firefox also supports: "audio/ogg"
};
var recordRTC = RecordRTC(stream, options);
```
|Media File|Bitrate/Framerate|encoders|Framesize|additional info|
| ------------- |-------------|-------------|-------------|-------------|
|Audio File (WAV) | 1411 kbps | pcm_s16le |44100 Hz|stereo, s16|
|Video File (WebM)|60 kb/s | (whammy) vp8 codec yuv420p|--|SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)|
## RecordRTC Demos
1. [RecordRTC to Node.js](https://github.com/muaz-khan/RecordRTC/tree/master/RecordRTC-to-Nodejs)
2. [RecordRTC to PHP](https://github.com/muaz-khan/RecordRTC/tree/master/RecordRTC-to-PHP)
3. [RecordRTC to ASP.NET MVC](https://github.com/muaz-khan/RecordRTC/tree/master/RecordRTC-to-ASPNETMVC)
4. [RecordRTC & HTML-2-Canvas i.e. Canvas/HTML Recording!](https://github.com/muaz-khan/RecordRTC/tree/master/Canvas-Recording)
5. [MRecordRTC i.e. Multi-RecordRTC!](https://github.com/muaz-khan/RecordRTC/tree/master/MRecordRTC)
6. [RecordRTC on Ruby!](https://github.com/cbetta/record-rtc-experiment)
7. [RecordRTC over Socket.io](https://github.com/muaz-khan/RecordRTC/tree/master/RecordRTC-over-Socketio)
8. [ffmpeg-asm.js and RecordRTC! Audio/Video Merging & Transcoding!](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/ffmpeg)
9. [RecordRTC / PHP / FFmpeg](https://github.com/muaz-khan/RecordRTC/tree/master/PHP-and-FFmpeg)
10. [Record Audio and upload to Nodejs server](https://www.npmjs.org/package/record-audio)
11. [ConcatenateBlobs.js](https://github.com/muaz-khan/ConcatenateBlobs) - Concatenate multiple recordings in single Blob!
12. [Remote audio-stream recording](https://www.webrtc-experiment.com/demos/remote-stream-recording.html) or [a real p2p demo](https://www.webrtc-experiment.com/RTCMultiConnection/RecordRTC-and-RTCMultiConnection.html)
13. [Mp3 or Wav Recording](https://www.webrtc-experiment.com/RecordRTC/Record-Mp3-or-Wav.html)
14. [Record entire DIV including video, image, textarea, input, drag/move/resize, everything](https://www.webrtc-experiment.com/RecordRTC/Canvas-Recording/)
15. [Record canvas 2D drawings, lines, shapes, texts, images, drag/resize/enlarge/move via a huge drawing tool!](https://www.webrtc-experiment.com/RecordRTC/Canvas-Recording/record-canvas-drawings.html)
16. [Record Canvas2D Animation](https://www.webrtc-experiment.com/RecordRTC/Canvas-Recording/Canvas-Animation-Recording.html)
17. [WebGL animation recording](https://www.webrtc-experiment.com/RecordRTC/webgl/)
18. [Plotly - WebGL animation recording](https://www.webrtc-experiment.com/RecordRTC/plotly.html)
You can also try a chrome extension for screen recording:
* https://chrome.google.com/webstore/detail/recordrtc/ndcljioonkecdnaaihodjgiliohngojp
# How to link?
## [NPM](https://www.npmjs.com/package/recordrtc) install
```
npm install recordrtc
# you can use with "require" (browserify/nodejs)
var RecordRTC = require('recordrtc');
var recorder = RecordRTC({}, {
type: 'video',
recorderType: RecordRTC.WhammyRecorder
});
console.log('\n--------\nRecordRTC\n--------\n');
console.log(recorder);
console.log('\n--------\nstartRecording\n--------\n');
recorder.startRecording();
console.log('\n--------\nprocess.exit()\n--------\n');
process.exit()
```
* https://tonicdev.com/npm/recordrtc
Here is how to use `require`:
```javascript
var RecordRTC = require('recordrtc');
var Whammy = RecordRTC.Whammy;
var WhammyRecorder = RecordRTC.WhammyRecorder;
var StereoAudioRecorder = RecordRTC.StereoAudioRecorder;
// and so on
var video = new Whammy.Video(100);
var recorder = new StereoAudioRecorder(stream, options);
```
```html
```
There are some other NPM packages regarding RecordRTC:
* [https://www.npmjs.org/search?q=RecordRTC](https://www.npmjs.org/search?q=RecordRTC)
## [bower](http://bower.io) install
```
bower install recordrtc
```
```html
```
## CDN
```html
```
Otherwise check cdnjs below.
## Releases
You can even link specific [releases](https://github.com/muaz-khan/RecordRTC/releases):
```html
```
Note: You can use `RecordRTC.min.js` as well. (on webrtc-experiment or cdnjs)
## How to capture stream?
```html
```
## Record audio+video
You'll be recording both audio/video in single WebM or Mp4 container.
```javascript
var recordRTC;
function successCallback(stream) {
// RecordRTC usage goes here
var options = {
mimeType: 'video/webm', // or video/webm\;codecs=h264 or video/webm\;codecs=vp9
audioBitsPerSecond: 128000,
videoBitsPerSecond: 128000,
bitsPerSecond: 128000 // if this line is provided, skip above two
};
recordRTC = RecordRTC(stream, options);
recordRTC.startRecording();
}
function errorCallback(error) {
// maybe another application is using the device
}
var mediaConstraints = { video: true, audio: true };
navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);
btnStopRecording.onclick = function () {
recordRTC.stopRecording(function (audioVideoWebMURL) {
video.src = audioVideoWebMURL;
var recordedBlob = recordRTC.getBlob();
recordRTC.getDataURL(function(dataURL) { });
});
};
```
## Record only Audio
```javascript
var recordRTC = RecordRTC(audioStream, { type: 'audio' });
recordRTC.startRecording();
recordRTC.stopRecording(function(audioURL) {
audio.src = audioURL;
var recordedBlob = recordRTC.getBlob();
recordRTC.getDataURL(function(dataURL) { });
});
```
## `options`
RecordRTC requires a second parameter named as `options` or `configuration` or `hints` or `preferences`:
```javascript
var options = {
recorderType: MediaStreamRecorder,
mimeType: 'video/webm\;codecs=vp9'
};
var recordRTC = RecordRTC(stream, options);
```
You can pass `options` object over `startRecording` method as well:
```javascript
var recordRTC = RecordRTC(stream);
var options = {
recorderType: MediaStreamRecorder,
mimeType: 'video/webm\;codecs=vp9'
};
recordRTC.startRecording(options);
```
* `type` accepts `video` or `audio` or `canvas` or `gif`
* `mimeType` accepts [all these values](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/mimeType)
* `recorderType` accepts `MediaStreamRecorder` or `StereoAudioRecorder` or `WhammyRecorder` or `GifRecorder` or any recorder type from [this page](https://github.com/muaz-khan/RecordRTC/tree/master/dev)
* `timeSlice` accepts numbers in milliseconds; use this to force intervals-based blobs
* `ondataavailable` pass this function along with `timeSlice` to get intervals based blobs
* `checkForInactiveTracks` accepts `true` or `false`; use this to disable default inactive-stream-checker functions
* `onTimeStamp` it is a function that is called-back by the MediaStreamRecorder; `timeSlice` parameter is required for this function
* `bitsPerSecond` accepts numbers in bits; applies both to audio and video tracks
* `audioBitsPerSecond` accepts numbers in bits; applies only to audio tracks
* `videoBitsPerSecond` accepts numbers in bits; applies only to video tracks
* `disableLogs` accepts `true` or `false`; use this to disable console logs
* `frameInterval` accepts numbers in milliseconds; use this with MultiStreamRecorder, CanvasRecorder and WhammyRecorder
* `previewStream` it is a function that is called-back by the MultiStreamRecorder
* `video` accepts object similar to this: `{width: 320, height: 240}`; pass this parameter for MultiStreamRecorder, CanvasRecorder and WhammyRecorder
* `canvas` accepts object similar to this: `{width: 320, height: 240}`; pass this parameter for MultiStreamRecorder, CanvasRecorder and WhammyRecorder
* `sampleRate` used only by the StereoAudioRecorder
* `bufferSize` used only by the StereoAudioRecorder
* `numberOfAudioChannels` used only by the StereoAudioRecorder
## Record Multiple Videos
Demos:
1. [Record all your cameras](https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/multi-cameras-recording.html)
2. [Record screen as well as your video!](https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/video-plus-screen-recording.html)
You can record many videos/streams in single WebM/Mp4 file (**WebRTC Conference Recording**):
```javascript
var arrayOfStreams = [localStream, remoteStream1, remoteStream2, remoteStream3];
var recordRTC = RecordRTC(arrayOfStreams, {
type: 'video',
mimeType: 'video/webm', // or video/webm\;codecs=h264 or video/webm\;codecs=vp9
previewStream: function(stream) {
// it is optional
// it allows you preview the recording video
}
});
recordRTC.startRecording();
recordRTC.stopRecording(function(singleWebM) {
video.src = singleWebM;
var recordedBlob = recordRTC.getBlob();
recordRTC.getDataURL(function(dataURL) { });
});
```
Points:
1. Instead of passing single `MediaStream`, you are passing array of `MediaStreams`
2. You will get single webm or mp4 according to your `mimeType`
`MultiStreamRecorder.js` supports two extra methods:
1. `addStreams`
2. `resetVideoStreams`
```javascript
var msRecorder = recorder.getInternalRecorder();
if (msRecorder instanceof MultiStreamRecorder) {
msRecorder.addStreams([newAudioStream]);
msRecorder.resetVideoStreams([screenStream]);
}
```
Usecases:
1. You can add more audio and/or video streams during live recording (using `addStreams` method)
2. You can reset/remove/replace old videos using `resetVideoStreams`
`resetVideoStreams` can be used to recorded screenStream in full-screen mode e.g.
```javascript
if (yourScreen.isScreen === true) {
yourScreen.fullcanvas = true;
yourScreen.width = window.screen.width;
yourScreen.height = window.screen.height;
// now it will record all audios + only_this_screen
internalRecorder.resetVideoStreams([yourScreen]);
}
```
As soon as [screen is stopped](https://www.webrtc-experiment.com/webrtcpedia/#stream-ended-listener):
```javascript
addStreamStopListener(yourScreen, function() {
var cameraStreams = getSingleOrMultipleCameraStreams();
// now it will record all audios + all_your_cameras
internalRecorder.resetVideoStreams(cameraStreams);
});
```
## `getInternalRecorder`
You can get access to internal recorders e.g. MultiStreamRecorder, MediaStreamRecorder, StereoAudioRecorder, WhammyRecorder etc.
> Use `getInternalRecorder` only after `startRecording`. It may return `NULL` according to RecordRTC current state.
```javascript
// if RecordRTC recording in-progress
if (recorder.state === 'recording') {
// get MediaStreamRecorder
var msRecorder = recorder.getInternalRecorder();
// always check for NULL or verify the recorder type
if (msRecorder instanceof MultiStreamRecorder) {
// it is NOT NULL
// also it is MultiStreamRecorder instance
// now we can use these extra methods
msRecorder.addStreams([newAudioStream]);
msRecorder.resetVideoStreams([screenStream]);
}
}
```
Internal recorders can add extra methods. Same as MultiStreamRecorder which is supporting two extra methods:
1. `addStreams`
2. `resetVideoStreams`
## `onStateChanged`
Use this method to detect status of the recording:
```javascript
recorder = RecordRTC(stream, {
type: 'video',
onStateChanged: function(state) {
alert('Current recorder status: ' + state);
}
});
recorder.startRecording();
```
## `state`
Use this property to detect status of the recording:
```javascript
recorder = RecordRTC(stream, {
type: 'video'
});
alert('Current recorder status: ' + recorder.state);
recorder.startRecording();
alert('Current recorder status: ' + recorder.state);
recorder.stopRecording(function() {
alert('Current recorder status: ' + recorder.state);
});
```
You can even use `getState` method:
```javascript
alert('Current recorder status: ' + recorder.getState());
```
## `version`
Detect current RecordRTC version:
```javascript
recorder = RecordRTC(stream, {
type: 'video'
});
alert('Current recorder version: ' + recorder.version);
```
You can even use `RecordRTC.version`:
```javascript
alert('Current recorder version: ' + RecordRTC.version);
```
## Echo Issues
Simply set `volume=0` or `muted=true` over `