This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage 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 specification changes.

The captureStream() property of the HTMLMediaElement interface returns a MediaStream object which is streaming a real-time capture of the content being rendered in the media element.


var mediaStream = mediaElement.captureStream()




MediaStream object which can be used as a source for audio and/or video data by other media processing code, or as a source for WebRTC.


In this example, an event handler is established so that clicking a button starts capturing the contents of a media element with the ID "playback" into a MediaStream. The stream can then be used for other purposes—like a source for streaming over WebRTC, to allow sharing prerecorded videos with another person during a video call.

document.querySelector('.playAndRecord').addEventListener('click', function() {
  var playbackElement = document.getElementById("playback");
  var captureStream = playbackElement.captureStream();;


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

Browser Compatibility

Feature Chrome Firefox (Gecko)[1] Microsoft Edge Internet Explorer Opera Safari (WebKit)
Basic support 53.0 15 (15) -moz ? ? ? ?
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 53.0 ? ? ? ? ? 53.0

[1] Prior to Firefox 51, you couldn't use captureStream() on a media element whose source is, itself, a MediaStream (like a <video> element which is presenting a stream being received over a RTCPeerConnection). Beginning in Firefox 51, this works. This means you can capture a stream from the video element and use MediaRecorder to record it. See bug 1259788 for details.

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, GeraldNDA, jpmedley
 Last updated by: Sheppy,