[英]RecordRTC making noise without headphone video recording
我是RecordRTC.js的新手,我有一個簡單的應用程序,可以錄制音頻和視頻並保存該視頻。 如果我使用耳機錄制視頻,這工作正常。 但是,如果我卸下耳機並嘗試錄制視頻,則會產生一些可怕的噪音。 會發生一些時間,例如,如果我刷新頁面,則不會發出聲音,但是如果我插入耳機並取下耳機,然后按錄音按鈕,則它會開始發出聲音。
這是我的代碼開始記錄。
function captureUserMedia(mediaConstraints, successCallback, errorCallback) {
navigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);
}
function onMediaSuccess(stream) {
streamMedia = stream;
var videoPreview = document.getElementById('webrtcVideo');
var videoFile = !!navigator.mozGetUserMedia ? 'video.gif' : 'video.webm';
videoPreview.src = window.URL.createObjectURL(stream);
videoPreview.play();
recordVideo = RecordRTC(stream, {
type: 'video'
});
recordVideo.startRecording();
}
function onMediaError(e) {
console.error('media error', e);
}
/**
* This function will be called from html on click of record button.
*/
function startRecording() {
captureUserMedia(mediaConstraints, onMediaSuccess, onMediaError);
}
var mediaConstraints = {
video: true,
audio: {
mandatory: {
echoCancellation: false,
googAutoGainControl: false,
googNoiseSuppression: false,
googHighpassFilter: false
},
optional: [{
googAudioMirroring: false
}]
},
};
function captureUserMedia(mediaConstraints, successCallback,errorCallback) {
navigator.mediaDevices.getUserMedia(mediaConstraints)
.then(successCallback)
.catch(errorCallback);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.