小编Abe*_*ruz的帖子

How to download a recording using getUsermedia and mediaRecorder and give the video specifications?

navigator.mediaDevices.getUserMedia().then(stream=>{

//a recorder is created
var mediaRecorder = new MediaRecorder(stream);

//started it
mediaRecorder.start();

//an array is created that receives all the data
var recordedChunks = [];

//fill it
mediaRecorder.ondataavailable = function(e){recordedChunks.push(e.data)};

//when stopped downloads the recording
mediaRecorder.onstop=function(){

  var blob = new Blob(recordedChunks, {
    'type': 'video/mp4'
  });
  var url = URL.createObjectURL(blob);
  var a = document.createElement('a');
  document.body.appendChild(a);
  a.style = 'display: none';
  a.href = url;
  a.download = 'test.webm';
  a.click();
  window.URL.revokeObjectURL(url);
}
}.catch()
Run Code Online (Sandbox Code Playgroud)

This code works for me, but when the video is downloaded …

javascript video-capture getusermedia web-mediarecorder mediadevices

5
推荐指数
1
解决办法
2596
查看次数