Last active
April 4, 2023 18:00
-
-
Save ravenjohn/e6404ac91761c4b5b2f388a41f5ac0c2 to your computer and use it in GitHub Desktop.
Get VideoFrame format
This file contains 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
(() => { | |
// change value of querySelector to whatever is needed to select the element, e.g. #my-canvas, #my-video | |
const el = document.querySelector('canvas'); | |
const stream = el.captureStream(30); | |
const track = stream.getVideoTracks()[0]; | |
const { readable } = new MediaStreamTrackProcessor({ track }); | |
const reader = readable.getReader(); | |
const read = async () => { | |
const { done, value} = await reader.read(); | |
if (done) { | |
return; | |
} | |
const frame = value; | |
console.log('frame format', frame.format); | |
frame.close(); | |
// uncomment if we want to keep reading | |
// read(); | |
} | |
read(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment