Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created November 19, 2024 22:09
Show Gist options
  • Save hubgit/39b14fe937df0747748559ac5afcef82 to your computer and use it in GitHub Desktop.
Save hubgit/39b14fe937df0747748559ac5afcef82 to your computer and use it in GitHub Desktop.
Record video + audio from a browser tab/window/screen
const media = await navigator.mediaDevices.getDisplayMedia({
audio: {
echoCancellation: false,
autoGainControl: false,
noiseSuppression: false,
},
})
const recorder = new MediaRecorder(media, {
mimeType: 'video/webm',
})
recorder.ondataavailable = (event) => {
event.data.stream().pipeTo(writableStream)
}
recorder.start()
const fileHandle = await window.showSaveFilePicker({
startIn: 'desktop',
suggestedName: 'output.webm',
})
const writableStream = await fileHandle.createWritable()
// recorder.requestData()
// recorder.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment