MediaRecorder.mimeType

The mimeType read-only property returns the MIME media type that was specified when creating the MediaRecorder object, or, if none was specified, which was chosen by the browser. This is the file format of the file that would result from writing all of the recorded data to disk.

Keep in mind that not all codecs are supported by a given container; if you write media using a codec that is not supported by a given media container, the resulting file may not work reliably if at all when you try to play it back. See our media type and format guide for information about container and codec support across browsers.

Note: The term "MIME type" is officially considered to be historical; these strings are now officially known as media types. MDN Web Docs content uses the terms interchangeably.

Syntax

var mimeType = mediaRecorder.mimeType

Value

The MIME media type which describes the format of the recorded media, as a DOMString. This string may include the codecs parameter, giving details about the codecs and the codec configurations used by the media recorder.

The media type strings are standardized by the Internet Assigned Numbers Authority (IANA). For their official list of defined media type strings, see the article Media Types on the IANA site. See also media types to learn more about media types and how they're used in web content and by web browers.

Example

...

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

  var constraints = { audio: true, video: true };
  var chunks = [];

  navigator.mediaDevices.getUserMedia(constraints)
    .then(function(stream) {
      var options = {
        audioBitsPerSecond: 128000,
        videoBitsPerSecond: 2500000,
        mimeType: 'video/mp4'
      }
      var mediaRecorder = new MediaRecorder(stream,options);
      m = mediaRecorder;

      m.mimeType; // would return 'video/mp4'
      ...
    })
    .catch(function(error) {
      console.log(error.message);
    });

Changing line 14 to the following causes MediaRecorder to try to use AVC Constrained Baseline Profile Level 4 for video and AAC-LC (Low Complexity) for audio, which is good for mobile and other possible resource-constrained situations.

mimeType: 'video/mp4; codecs="avc1.424028, mp4a.40.2"'

Assuming this configuration is acceptable to the user agent, the value returned later by m.mimeType would then be video/mp4; codecs="avc1.424028, mp4a.40.2".

Specifications

Specification Status Comment
MediaStream Recording
The definition of 'MediaRecorder.mimeType' in that specification.
Working Draft Initial definition

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
mimeTypeChrome Full support 49
Full support 49
No support 47 — 49
Notes
Notes Prior to Chrome 49, only video is supported, not audio.
Edge Full support 79Firefox Full support 25
Notes
Full support 25
Notes
Notes Starting with Firefox 71, the behavior of mimeType is more consistent. For example, it now returns the media type even after recording has stopped.
IE No support NoOpera Full support 36Safari No support NoWebView Android Full support 49
Full support 49
No support 47 — 49
Notes
Notes Prior to Chrome 49, only video is supported, not audio.
Chrome Android Full support 49
Full support 49
No support 47 — 49
Notes
Notes Prior to Chrome 49, only video is supported, not audio.
Firefox Android Full support 25Opera Android Full support 36Safari iOS No support NoSamsung Internet Android Full support 5.0

Legend

Full support
Full support
No support
No support
See implementation notes.
See implementation notes.

See also