Skip to content

Instantly share code, notes, and snippets.

@kyktommy
Created December 31, 2022 15:00
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 kyktommy/89ad836527f58b700dacd6a79a7d122f to your computer and use it in GitHub Desktop.
Save kyktommy/89ad836527f58b700dacd6a79a7d122f to your computer and use it in GitHub Desktop.
Screen capture
navigator.mediaDevices.getDisplayMedia({video:true}).then(function(stream){
const mr=new MediaRecorder(stream,{mimeType:"video/webm;codecs=h264,opus"});
mr.ondataavailable=function(ev){
const a=document.createElement('a');a.href=URL.createObjectURL(ev.data);
a.download ='screen_capture.webm';a.click();
}; // will be called when .stop() with ev.data as a Blob
mr.start();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment