Skip to content

Instantly share code, notes, and snippets.

@christianselig
Created March 1, 2024 17:54
Show Gist options
  • Save christianselig/66fade4ecfc909183dec554a0be595e3 to your computer and use it in GitHub Desktop.
Save christianselig/66fade4ecfc909183dec554a0be595e3 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
video {
width: 1920px;
}
canvas {
position: fixed;
}
</style>
</head>
<body>
<video src="https://christianselig.com/bunny.mp4" controls autoplay loop muted></video>
<script>
let canvas = undefined;
let ctx = undefined;
setInterval(function() {
const video = document.querySelector('video');
if (!canvas) {
canvas = document.createElement('canvas');
document.body.prepend(canvas);
ctx = canvas.getContext('2d');
canvas.style.width = 1920;
canvas.style.height = 1080;
}
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
}, 40);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment