Javascript 尝试设置画布宽度和视频宽度,但使用object Objectt进行应答
我正在尝试修改我正在录制的视频和音频默认设置,但由于任何原因我不知道,它不起作用。 我在开始记录时得到的是:Javascript 尝试设置画布宽度和视频宽度,但使用object Objectt进行应答,javascript,webrtc,Javascript,Webrtc,我正在尝试修改我正在录制的视频和音频默认设置,但由于任何原因我不知道,它不起作用。 我在开始记录时得到的是: started recording audio stream. sample-rate 48000 buffer-size 4096 started recording [Object Object] stream. sample-rate 48000 buffer-size 4096 主要问题是“开始录制”,它返回[对象]。它应该返回宽度和高度大小。似乎我没有正确设置强制变量 下面我
started recording audio stream.
sample-rate 48000
buffer-size 4096
started recording [Object Object] stream.
sample-rate 48000
buffer-size 4096
主要问题是“开始录制”,它返回[对象]
。它应该返回宽度和高度大小。似乎我没有正确设置强制变量
下面我粘贴我的代码:
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();
}
}
有人能帮我吗
谢谢你的建议。是的,如果你只想录制视频,那么第二个参数应该是
{type:'video'}
这里您没有传递这个视频
参数,因此我认为它试图录制一个强制
,这可能会失败
要删除录制的视频的内容,选项应如下所示
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);
:灯泡:添加相关代码将是一个良好的开端。要求海报提供MCVE是有原因的。()如果看不到最初输出消息的代码(
开始录制[Object]流
),就可以决定是否玩猜谜游戏。@kaido-用户不发布MVCE有很多原因。这些问题几乎完全与提问者所面临的不便有关。和往常一样,当一个人让别人给予帮助变得容易时,他会得到更好的结果耸耸肩:@kaido-对于jQuery来说,这一点很公平,但它并没有阻止人们在发布MCVE时询问它的使用。谢谢你向我解释,输出来自库代码。我根本不知道在哪里放置选项。现在好了!谢谢