Generator that yields frames from a video element as ImageData.
import { Video } from'https://unpkg.com/ixfx/dist/visual.js'
constctx = canvasEl.getContext(`2d`); forawait (constframeofVideo.frames(videoEl)) { // TODO: Some processing of pixels
// Draw image on to the visible canvas ctx.putImageData(frame, 0, 0); }
Under the hood it creates a hidden canvas where frames are drawn to. This is necessary
to read back pixel data. An existing canvas can be used if it is passed in as an option.
Options:
canvasEl: CANVAS element to use as a buffer (optional)
maxIntervalMs: Max frame rate (0 by default, ie runs as fast as possible)
showCanvas: Whether buffer canvas will be shown (false by default)
Generator that yields frames from a video element as ImageData.
Under the hood it creates a hidden canvas where frames are drawn to. This is necessary to read back pixel data. An existing canvas can be used if it is passed in as an option.
Options:
canvasEl
: CANVAS element to use as a buffer (optional)maxIntervalMs
: Max frame rate (0 by default, ie runs as fast as possible)showCanvas
: Whether buffer canvas will be shown (false by default)