Skip to content

Instantly share code, notes, and snippets.

@dublado
Created April 22, 2025 04:48
Show Gist options
  • Save dublado/ae98cff133532468544764faecdf87f5 to your computer and use it in GitHub Desktop.
Save dublado/ae98cff133532468544764faecdf87f5 to your computer and use it in GitHub Desktop.
download blob
(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