MediaRecorder.MediaRecorder()

The MediaRecorder() constructor creates a new MediaRecorder object.

Syntax

var m = new MediaRecorder(stream, options);

Parameters

mimeType Optional
The mime type you want to use as the recording container for the new MediaRecorder.
stream
The media stream that will be recorded (for example, from a getUserMedia instance.)

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.
  • 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.

Note: 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, dependant on the sample rate and number of channels.

Example

...


if (navigator.getUserMedia) {
  console.log('getUserMedia supported.');

  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;

...

Specifications

Specification Status Comment
MediaStream Recording Working Draft Initial definition

Note: The options as they are in this document are not yet specified in the specification. The specification currently shows only the stream and mimeType as available parameters.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 47[2] 25.0 (25.0) Not supported Not supported Not supported
options object Not supported 43.0 (43.0) Not supported Not supported Not supported
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support Not supported Not supported 25.0 (25.0) 1.3[1] Not supported Not supported Not supported Not supported

[1] The intial Firefox OS implementation only supported audio recording.

[2] To try this feature on Chrome, enable Experimental Web Platform features from chrome://flags . Currently only video is supported, not audio.

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, chrisdavidmills
 Last updated by: jpmedley,