是否有可能将RecordRTC中的“画布”记录器和“音频”记录器功能结合起来,创建一个.webm视频,其中画布动画作为视频,麦克风输入作为音频?
发布于 2017-05-09 13:02:58
是啊。您可以将Canva-2d以及麦克风记录到单个WebM容器中。
navigator.getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia || navigator.webkitGetUserMedia;
navigator.getUserMedia({
audio: true
}, funtion(microphone) {
var canvasStream = canvas.captureStream(25);
microphone.getAudioTracks().forEach(function(track) {
// merge microphone into canvas stream
canvasStream.addTrack(track);
});
// now your canvas stream has both audio and video tracks
// now you can record it using RecordRTC
var recorder = RecordRTC(canvasStream, {
type: 'video'
});
// auto stop after 5 seconds recording
recorder.setRecordingDuration(5 * 1000).onRecordingStopped(function() {
var url = recorder.toURL();
window.open(url);
var blob = recorder.getBlob();
var singleWebM = new File([blob], 'single.webm', {
type: 'video/webm'
});
});
recorder.startRecording();
}, function(error) {
alert('unable to access your microphone');
});有关更多信息,请查看:WebRTC captureStream API
https://stackoverflow.com/questions/43869788
复制相似问题