【发布时间】:2014-01-18 09:36:34
【问题描述】:
我正在尝试使用 Chrome 的屏幕共享功能制作屏幕录像机并将视频保存为 MP4 格式。但是,我不知道我是如何做到这一点的。演示在https://figgycity50.kd.io/screencap.html(包括https!),代码是:
<video autoplay></video>
<button>start</button>
<script>
navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.getUserMedia;
var stream = null;
button = document.querySelector("button");
function start(e) {
// Seems to only work over SSL.
navigator.getUserMedia({
video: {
mandatory: {
chromeMediaSource: 'screen',
maxWidth: 1280,
maxHeight: 720
}
}
}, function(s) {
stream = s;
button.textContent = 'Stop';
button.removeEventListener('click', start);
button.addEventListener('click', stop);
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(stream);
video.autoplay = true;
stream.onended = function(e) {
//The save code should go here.
};
//document.body.appendChild(video);
}, function(e) {
});
}
function stop() {
stream.stop();
button.addEventListener('click', start);
button.textContent = 'Capture your screen';
}
button.addEventListener('click', start);
</script>
我该怎么做?
【问题讨论】:
标签: html video save export mp4