Created
April 22, 2025 04:48
-
-
Save dublado/ae98cff133532468544764faecdf87f5 to your computer and use it in GitHub Desktop.
download blob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const video = document.querySelector('video'); | |
const stream = video.captureStream(); | |
const recorder = new MediaRecorder(stream); | |
const chunks = []; | |
recorder.ondataavailable = e => chunks.push(e.data); | |
recorder.onstop = async () => { | |
const blob = new Blob(chunks, { type: 'video/webm' }); | |
const url = URL.createObjectURL(blob); | |
const a = document.createElement('a'); | |
a.href = url; | |
a.download = 'video.webm'; | |
a.click(); | |
}; | |
recorder.start(); | |
video.play(); | |
setTimeout(() => recorder.stop(), video.duration * 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment