我正在尝试修改我正在录制的视频和音频默认设置,但出于任何原因我不知道,它不起作用。 我在开始时得到的记录是:
started recording audio stream.
sample-rate 48000
buffer-size 4096
started recording [Object Object] stream.
sample-rate 48000
buffer-size 4096
主要问题是“开始录制”,返回[Object Object]
。它应该返回宽度和高度尺寸。我似乎没有正确设置强制变量。
下面我粘贴我的代码:
var video = $('preview')[0],
audio,
fileName,
replay,
blob,
timer,
streaming,
isFirefox = !!navigator.mozGetUserMedia,
recordAudio,
recordVideo,
progress,
upload_bar,
seconds,
video_constraints = { mandatory: { minWidth: 1280, minHeight: 720, minFrameRate: 30}, optional: [] };
//If getUserMedia is soported by our browser and we allow to use it, our video tag will show the stream we're recording.
function success(stream) {
'use strict';
video = $('#preview')[0];
video.src = window.URL.createObjectURL(stream);
video.play();
video.muted = true;
if (!isFirefox) {
window.stream = stream;
} else {
audio = document.querySelector('audio');
streaming = stream;
}
$('#start-camara').hide();
$('#round-record').css('display', 'block');
$('.record-actions').css('justify-content', 'center');
setTimeout(function () {
$('#preview').css('width', 'auto');
}, 1255);
$('#round-record > path').on('click', function () {
if (!isFirefox) {
$('#splitbar-pause').css('display', 'block');
}
if (!video.src) {
window.alert("there must be an error with your video");
return;
} else {
$('#square-stop').css('display', 'block');
$('#round-record').css('display', 'none');
}
countdown();
recordAudio = new RecordRTC(stream, {
// bufferSize: 16384,
onAudioProcessStarted: function () {
if (!isFirefox) {
recordVideo.startRecording();
}
}
});
recordVideo = new RecordRTC(stream, {
type: video_constraints
});
recordAudio.startRecording();
});
}
// Sets a poster error when there's no posibility to load the camera
function error(e) {
'use strict';
if (!video.hasAttribute("poster")) {
video.setAttribute("poster", "img/nocamera.png");
}
}
// Check the webRTC library compatible with the browser
function checkCompatibility() {
'use strict';
return !!(navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
}
function startCamera() {
'use strict';
if (!checkCompatibility()) {
error();
}
if (!window.stream && navigator.getUserMedia) {
navigator.getUserMedia({
audio: true,
video: video_constraints
}, success, error);
} else {
error();
}
}
有人可以帮我这个吗?
感谢您的建议。
答案 0 :(得分:2)
是的,如果您只想录制视频,则recordRTC(stream, options)
的第二个参数应为{type: 'video'}
。
这里你没有传递这个video
参数,所以我认为它试图记录mandatory
,这可能会失败。
要录制视频的constrain the width/height,选项应如下
var options = {
type: 'video', // Mandatory STRING
video: {
width: 320,
height: 240
},
canvas: {
width: 320,
height: 240
}
};
var recordVideo = RecordRTC(MediaStream, options);
您甚至可以设置宽度/高度:
var options = {
type: 'video', // Mandatory STRING
width: 1920,
height: 1280
};
var recordVideo = RecordRTC(MediaStream, options);