MCPcopy Create free account
hub / github.com/core7s/react-design-editor / captureFrame

Function captureFrame

src/utils/video.ts:22–41  ·  view source on GitHub ↗
(video: HTMLVideoElement)

Source from the content-addressed store, hash-verified

20}
21
22export const captureFrame = (video: HTMLVideoElement): Promise<string> => {
23 return new Promise(function (resolve) {
24 const canvas = document.createElement("canvas") as HTMLCanvasElement
25 canvas.width = video.videoWidth
26 canvas.height = video.videoHeight
27 canvas.getContext("2d")!.drawImage(video, 0, 0, canvas.width, canvas.height)
28 URL.revokeObjectURL(video.src)
29
30 const data = canvas.toDataURL()
31
32 fetch(data)
33 .then((res) => {
34 return res.blob()
35 })
36 .then((blob) => {
37 const url = URL.createObjectURL(blob)
38 resolve(url)
39 })
40 })
41}
42
43export const captureDuration = (video: HTMLVideoElement) => {
44 return new Promise((resolve) => {

Callers 2

handleDropFilesFunction · 0.90
loadVideoEditorAssetsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected