The MediaRecorder() constructor creates a new MediaRecorder object that will record a specified MediaStream. The object can optionally be configured to record using a specific media container (file type).


var mediaRecorder = new MediaRecorder(stream[, options]);


The MediaStream that will be recorded. This source media can come from a stream created using navigator.mediaDevices.getUserMedia() or from an <audio>, <video> or <canvas> element.

options Optional

A dictionary object that can contain the following properties:

  • mimeType: The MIME type you want to use as the recording container for the new MediaRecorder. This field may simply specify the container format (allowing the browser to choose its preferred codecs) or may include the codec and/or profile options to use. Applications can check in advance if this mimeType is supported by the user agent by calling MediaRecorder.isTypeSupported().
  • audioBitsPerSecond: The chosen bitrate for the audio component of the media.
  • videoBitsPerSecond: The chosen bitrate for the video component of the media.
  • bitsPerSecond: The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified.

If bits per second values are not specified for video and/or audio, the default adopted for video is 2.5Mbps, while the audio default is adaptive, depending upon the sample rate and the number of channels.


This example shows how to create a media recorder for a specified stream, whose audio bit rate is set to 128Kbit/sec and whose video bit rate is set to 2.5 Mbit/sec. The recorded media data will be stored in an MP4 wrapper (so if you gather the chunks of media data and save them to disk, they will be in an MP4 file).


if (navigator.mediaDevices.getUserMedia) {
  var constraints = { audio: true, video: true };
  var chunks = [];

  var onSuccess = function(stream) {
    var options = {
      audioBitsPerSecond : 128000,
      videoBitsPerSecond : 2500000,
      mimeType : 'video/mp4'
    var mediaRecorder = new MediaRecorder(stream,options);
    m = mediaRecorder;



Specification Status Comment
MediaStream Recording Working Draft Initial definition

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
MediaRecorder() constructorChrome Full support 47Edge No support NoFirefox Full support 25IE ? Opera Full support 36Safari ? WebView Android Full support 47Chrome Android Full support 47Firefox Android Full support 25Opera Android Full support 36Safari iOS ? Samsung Internet Android Full support 5.0
options objectChrome Full support 49Edge No support NoFirefox Full support 43IE ? Opera Full support 36Safari ? WebView Android Full support 49Chrome Android Full support 49Firefox Android ? Opera Android Full support 36Safari iOS ? Samsung Internet Android No support No


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Last updated by: Sheppy,