Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 902 Bytes

capture_single_frame_from_a_html_video.mdx

File metadata and controls

24 lines (20 loc) · 902 Bytes
title date tag
Capture A Single Frame from a HTML Video
2024-04-03
html video console javascript

This is amazing idea similar to my No Ads Snippet. But this snippet you paste into the console of your browser will open a new window with the current frame you're paused on a video site (like YouTube – it works there!), and allow you you to then right-click and save that sweet frame of video.

Hat tip to the awesome Dave Rupert for the idea.

This will come in useful.

const v = document.querySelector('video')
let c = document.createElement('canvas')
c.height = v.videoHeight || parseInt(v.style.height)
c.width = v.videoWidth || parseInt(v.style.width)
const ctx = c.getContext('2d')
ctx.drawImage(v, 0, 0)
const wnd = window.open('')
wnd.document.write(`<img src="${c.toDataURL()}"/>`)