WebRTC samples Stream camera via a canvas to a video element

The camera is captured to a video element, which is mapped onto a canvas, and a red square is added.

The canvas is then captured to an ImageData object, and painted onto a second canvas.

A stream is captured from the second canvas element using its captureStream() method and set as the srcObject of the video element.

The inputStream, source, canvasIn, canvasOut, result, and stream variables are in global scope, so you can inspect them from the browser console.

View source on GitHub