This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The CanvasCaptureMediaStream.requestFrame() method forces a frame to be captured and sent to the stream. This allows to capture partially rendered frames.




// Find the canvas element to capture
var canvasElt = document.getElementsByTagName("canvas")[0];

// Get the stream
var stream = canvasElt.captureStream(25); // 25 FPS

// Send the current state of the canvas as a frame to the stream


Specification Status Comment
Media Capture from DOM Elements
The definition of 'CanvasCaptureMediaStream.requestFrame()' in that specification.
Editor's Draft Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 41 (41)[1] Not supported ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ?[1] 34.0 (34) Not supported ? ?

[1] Disabled by default; set the preference canvas.capturestream.enabled to true to activate.

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

CanvasCaptureMediaStream Experimental Method Reference