我试图修改我正在录制的视频和音频默认设置,但由于任何原因我不知道,它不工作。我一开始就开始记录的是:
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();
}
}有人能帮我吗?
谢谢你的建议。
发布于 2015-09-04 13:56:21
是的,如果您只想录制视频,recordRTC(stream, options)的第二个参数应该是{type: 'video'}。
这里您没有传递这个video参数,所以我认为它试图记录一个可能失败的mandatory。
对于录制的视频的限制宽度/高度,选项应该如下所示
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);https://stackoverflow.com/questions/32396932
复制相似问题