getusermedia php,HTML5 getUserMedia记录网络摄像头,音频和视频

MediaStreamRecorder是用于记录getUserMedia()流(仍在实现)的WebRTC API。它允许网络应用程序从现场音频/视频会话创建文件。

function onVideoFail(e) {

console.log('webcam fail!',e);

};

function hasGetUserMedia() {

// Note: Opera is unprefixed.

return !!(navigator.getUserMedia || navigator.webkitGetUserMedia ||

navigator.mozGetUserMedia || navigator.msGetUserMedia);

}

if (hasGetUserMedia()) {

// Good to go!

} else {

alert('getUserMedia() is not supported in your browser');

}

window.URL = window.URL || window.webkitURL;

navigator.getUserMedia = navigator.getUserMedia ||

navigator.webkitGetUserMedia ||

navigator.mozGetUserMedia ||

navigator.msGetUserMedia;

var video = document.querySelector('video');

var streamRecorder;

var webcamstream;

if (navigator.getUserMedia) {

navigator.getUserMedia({audio: true,video: true},function(stream) {

video.src = window.URL.createObjectURL(stream);

webcamstream = stream;

// streamrecorder = webcamstream.record();

},onVideoFail);

} else {

alert ('Failed');

}

function startRecording() {

streamRecorder = webcamstream.record();

setTimeout(stopRecording,10000);

}

function stopRecording() {

streamRecorder.getRecordedData(postVideoToServer);

}

function postVideoToServer(videoblob) {

var data = {};

data.video = videoblob;

data.Metadata = 'test Metadata';

data.action = "upload_video";

jQuery.post("http://www.foundthru.co.uk/uploadvideo.PHP",data,onUploadSuccess);

}

function onUploadSuccess() {

alert ('video uploaded');

}

RECORD

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值