Created
October 2, 2017 18:56
-
-
Save danhanfry/fab90f328101bb0434218edaef56fdaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have found a solution. Read here: muaz-khan/RecordRTC#181 | |
Here is a code that starts to record video+audio in Electron: | |
let recorder; | |
let blobs = []; | |
function captureScreenVideoWithAudio() { | |
navigator.webkitGetUserMedia({ | |
audio: true | |
}, function(audioStream) { | |
navigator.webkitGetUserMedia({ | |
audio: false, | |
video: { | |
mandatory: { | |
chromeMediaSource: 'screen', | |
minWidth: 1280, | |
minHeight: 720 | |
} | |
} | |
}, handleVideoStream(audioStream), handleUserMediaError); | |
}, function() {}); | |
} | |
function handleVideoStream(audioStream) { | |
return function(videoStream) { | |
if (audioStream) { | |
let audioTracks = audioStream.getAudioTracks(); | |
if (audioTracks.length > 0) { | |
videoStream.addTrack(audioTracks[0]); | |
} | |
} | |
recorder = new MediaRecorder(videoStream); | |
blobs = []; | |
recorder.ondataavailable = function(event) { | |
blobs.push(event.data); | |
}; | |
recorder.start(); | |
}; | |
} | |
function handleUserMediaError(e) { | |
console.error('handleUserMediaError', e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment