Media Capabilities API

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

Note: This feature is available in Web Workers.

The Media Capabilities API allows developers to determine decoding and encoding abilities of the device, exposing information such as whether media is supported and whether playback should be smooth and power efficient.

Concepts

There are a myriad of video and audio codecs. Different browsers support different media types and new media types are always being developed. With the Media Capabilities API, developers can ensure each user is getting the best bitrate and storage savings for their browser, device, and OS capabilities.

Whether a device uses hardware or software decoding impacts how smooth and power efficient the video decoding is and how efficient the playback will be. The Media Capabilities API enables developers to determine which codecs are supported and how performant a media file will be both in terms of smoothness and power efficiency.

The Media Capabilities API provide more powerful features than other APIs such as MediaRecorder.isTypeSupported() or HTMLMediaElement.canPlayType(), which only address general browser support, not performance.

To test support, smoothness, and power efficiency for encoding and decoding video or audio content, you use the MediaCapabilities interface's encodingInfo() and decodingInfo() methods.

Interfaces

MediaCapabilities

Provides information about the decoding abilities of the device, system and browser based on codecs, profile, resolution, and bitrates. The information can be used to serve optimal media streams to the user and determine if playback should be smooth and power efficient.

Extensions to other interfaces

A MediaCapabilities object that can expose information about the decoding and encoding capabilities for a given media format and output capabilities.

WorkerNavigator.mediaCapabilities Read only

A MediaCapabilities object that can expose information about the decoding and encoding capabilities for a given media format and output capabilities.

Examples

Detect audio file support and expected performance

This example defines an audio configuration then checks to see if the user agent supports decoding that media configuration, and whether it will perform well in terms of smoothness and power efficiency.

js
if ("mediaCapabilities" in navigator) {
  const audioFileConfiguration = {
    type: "file",
    audio: {
      contentType: "audio/mp3",
      channels: 2,
      bitrate: 132700,
      samplerate: 5200,
    },
  };

  navigator.mediaCapabilities
    .decodingInfo(audioFileConfiguration)
    .then((result) => {
      console.log(
        `This configuration is ${result.supported ? "" : "not "}supported,`,
      );
      console.log(`${result.smooth ? "" : "not "}smooth, and`);
      console.log(`${result.powerEfficient ? "" : "not "}power efficient.`);
    })
    .catch(() => {
      console.log(`decodingInfo error: ${contentType}`);
    });
}

Specifications

Specification
Media Capabilities
# media-capabilities-interface

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
MediaCapabilities
Chrome – Full support
Chrome 66 (Release date: 2018-04-17)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 63 (Release date: 2018-10-23)
footnote Full support
Opera – Full support
Opera 53 (Release date: 2018-05-10)
footnote Full support
Safari – Full support
Safari 13 (Release date: 2019-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 66 (Release date: 2018-04-17)
footnote Full support
Firefox for Android – Full support
Firefox for Android 63 (Release date: 2018-10-23)
footnote Full support
Opera Android – Full support
Opera Android 48 (Release date: 2018-11-08)
footnote Full support
Safari on iOS – Full support
Safari on iOS 13 (Release date: 2019-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 9 (Release date: 2018-09-15)
footnote Full support
WebView Android – Full support
WebView Android 66 (Release date: 2018-04-17)
footnote Full support
WebView on iOS – Full support
WebView on iOS 13 (Release date: 2019-09-19)
footnote Full support
decodingInfo
Chrome – Full support
Chrome 66 (Release date: 2018-04-17)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
Firefox – Full support
Firefox 63 (Release date: 2018-10-23)
footnote
footnote The webrtc value of the type option is named transmission.
footnote Before Firefox 101, decodingInfo() ignored codecs parameter options for av01 codecs (treating them as av1).
Opera – Full support
Opera 53 (Release date: 2018-05-10)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
Safari – Full support
Safari 13 (Release date: 2019-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 66 (Release date: 2018-04-17)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
Firefox for Android – Full support
Firefox for Android 63 (Release date: 2018-10-23)
footnote
footnote The webrtc value of the type option is named transmission.
footnote Before Firefox for Android 101, decodingInfo() ignored codecs parameter options for av01 codecs (treating them as av1).
Opera Android – Full support
Opera Android 48 (Release date: 2018-11-08)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
Safari on iOS – Full support
Safari on iOS 13 (Release date: 2019-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 9 (Release date: 2018-09-15)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
WebView Android – Full support
WebView Android 66 (Release date: 2018-04-17)
footnote
footnote codecs string can contain any subset of optional parameters (should be all or none).
footnote Errors if codecs string contains unexpected characters (should evaluate string up to character).
WebView on iOS – Full support
WebView on iOS 13 (Release date: 2019-09-19)
footnote Full support
configuration.keySystemConfiguration parameter
Chrome – Full support
Chrome 80 (Release date: 2020-02-04)
footnote Full support
Edge – Full support
Edge 80 (Release date: 2020-02-07)
footnote Full support
Firefox – Full support
Firefox 129 (Release date: 2024-08-06)
footnote Full support
Opera – Full support
Opera 67 (Release date: 2020-03-03)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 80 (Release date: 2020-02-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 129 (Release date: 2024-08-06)
footnote Full support
Opera Android – Full support
Opera Android 57 (Release date: 2020-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 13 (Release date: 2020-12-02)
footnote Full support
WebView Android – Full support
WebView Android 80 (Release date: 2020-02-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
encodingInfo
Chrome – Full support
Chrome 101 (Release date: 2022-04-26)
footnote Full support
Edge – Full support
Edge 101 (Release date: 2022-04-28)
footnote Full support
Firefox – Full support
Firefox 63 (Release date: 2018-10-23)
footnote
footnote The webrtc value of the type option is named transmission.
Opera – Full support
Opera 87 (Release date: 2022-05-17)
footnote Full support
Safari – Full support
Safari 15.4 (Release date: 2022-03-14)
footnote Full support
Chrome Android – Full support
Chrome Android 101 (Release date: 2022-04-26)
footnote Full support
Firefox for Android – Full support
Firefox for Android 63 (Release date: 2018-10-23)
footnote
footnote The webrtc value of the type option is named transmission.
Opera Android – Full support
Opera Android 70 (Release date: 2022-06-29)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15.4 (Release date: 2022-03-14)
footnote Full support
Samsung Internet – Full support
Samsung Internet 19 (Release date: 2022-11-01)
footnote Full support
WebView Android – Full support
WebView Android 101 (Release date: 2022-04-26)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15.4 (Release date: 2022-03-14)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

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

See also