Skip to content

Instantly share code, notes, and snippets.

@mcmoe
Last active June 26, 2020 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmoe/d20ec256dd10d2345b5aa26bc9544763 to your computer and use it in GitHub Desktop.
Save mcmoe/d20ec256dd10d2345b5aa26bc9544763 to your computer and use it in GitHub Desktop.
Record a web mediaElement such as video
const stream = $0.captureStream();
const recorder = new MediaRecorder(stream);
const allChunks = [];
recorder.ondataavailable = (e) => allChunks.push(e.data);
recorder.start();
// recorder.pause();
// recorder.resume();
recorder.stop();
var fullBlob = new Blob(allChunks);
var link = document.createElement('a');
link.style.display = 'none';
var downloadUrl = window.URL.createObjectURL(fullBlob);
link.href = downloadUrl;
link.download = 'name-of-your-video.webm';
document.body.appendChild(link);
link.click();
link.remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment