From 792531b6fdd92a1bf484226759c8d809057631c3 Mon Sep 17 00:00:00 2001 From: Muaz Khan Date: Fri, 10 Feb 2017 10:00:03 +0500 Subject: [PATCH] Added MultiStreamRecorder i.e. conference-recorder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can pass up to 4 video streams (local and/or remote) and record all cameras in single WebM or Mp4 container. index.html demo now allows you record all cameras from your system: in single WebM/Mp4. Check the “readme.md” for “Record Multiple Videos” Simple demo included as well: RecordRTC/simple-demos/ --- Gruntfile.js | 3 +- README.md | 50 +++++- RecordRTC.js | 337 ++++++++++++++++++++++++++++++++++- RecordRTC.min.js | 6 +- dev/GetRecorderType.js | 6 +- dev/MediaStreamRecorder.js | 7 +- dev/MultiStreamRecorder.js | 321 +++++++++++++++++++++++++++++++++ index.html | 124 +++++++++++++ simple-demos/conference.html | 74 ++++++++ 9 files changed, 902 insertions(+), 26 deletions(-) create mode 100644 dev/MultiStreamRecorder.js create mode 100644 simple-demos/conference.html diff --git a/Gruntfile.js b/Gruntfile.js index 3d4e13c3..c137ced4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -49,7 +49,8 @@ module.exports = function(grunt) { 'dev/WhammyRecorder.js', 'dev/Whammy.js', 'dev/DiskStorage.js', - 'dev/GifRecorder.js' + 'dev/GifRecorder.js', + 'dev/MultiStreamRecorder.js' ], dest: 'RecordRTC.js', }, diff --git a/README.md b/README.md index 66f873fa..b53fc808 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Please check [dev](https://github.com/muaz-khan/RecordRTC/tree/master/dev) direc | 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 Separately | | Microsoft Edge | [Normal Build](https://www.microsoft.com/en-us/windows/microsoft-edge) | Only Audio | -## RecordRTC Encoders Format +## RecordRTC Containers Format #### vp9 @@ -187,9 +187,9 @@ navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catc ``` -## Record audio+video in Firefox +## Record audio+video -You'll be recording both audio/video in single WebM container. Though you can edit RecordRTC.js to record in mp4. +You'll be recording both audio/video in single WebM or Mp4 container. ```javascript var recordRTC; @@ -198,7 +198,7 @@ function successCallback(stream) { // RecordRTC usage goes here var options = { - mimeType: 'video/webm', // or video/mp4 or audio/ogg + 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 @@ -225,12 +225,10 @@ btnStopRecording.onclick = function () { }; ``` -Demo: [AudioVideo-on-Firefox.html](https://www.webrtc-experiment.com/RecordRTC/AudioVideo-on-Firefox.html) - ## Record only Audio ```javascript -var recordRTC = RecordRTC(mediaStream); +var recordRTC = RecordRTC(audioStream); recordRTC.startRecording(); recordRTC.stopRecording(function(audioURL) { audio.src = audioURL; @@ -240,6 +238,40 @@ recordRTC.stopRecording(function(audioURL) { }); ``` +## Record Multiple Videos + +You can record 4 parallel videos/streams (**WebRTC Conference**): + +```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(audioURL) { + audio.src = audioURL; + + var recordedBlob = recordRTC.getBlob(); + recordRTC.getDataURL(function(dataURL) { }); +}); +``` + +> This simply means that: **You can record 4 users video conference in single WebM or Mp4 container!** + +Note: This feature still requires `chrome://flags/#enable-experimental-web-platform-features` flag on Chrome. + +Points: + +1. Instead of passing single `MediaStream`, you are passing array of `MediaStreams` +2. You are keeping the `type=video` +3. You will get single webm or mp4 according to your `mimeType` + ## Echo Issues Simply set `volume=0` or `muted=true` over `