Skip to content

Instantly share code, notes, and snippets.

@ravenjohn
Last active April 4, 2023 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravenjohn/e6404ac91761c4b5b2f388a41f5ac0c2 to your computer and use it in GitHub Desktop.
Save ravenjohn/e6404ac91761c4b5b2f388a41f5ac0c2 to your computer and use it in GitHub Desktop.
Get VideoFrame format
(() => {
// 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