files/en-us/web/api/mediacapabilities/encodinginfo/index.md
{{APIRef("Media Capabilities API")}}{{AvailableInWorkers}}
The encodingInfo() method of the {{domxref("MediaCapabilities")}} interface returns a promise that fulfills with the tested media configuration's capabilities for encoding media.
This contains the three boolean properties supported, smooth, and powerefficient, which describe how compatible the device is with the type of media.
encodingInfo(configuration)
configuration
type and either a video or audio property containing a configuration of the appropriate type: <!-- MediaEncodingConfiguration in the spec -->
type
record
webrtc
transmission for this type, and webrtc does not work.transmission {{non-standard_inline}}
webrtc to be used in Firefox.video
contentType
codecs parameter.width
height
bitrate
framerate
audio
contentType
codecs parameter.channels
bitrate
samplerate
A {{jsxref('Promise')}} fulfilling with an object containing three Boolean attributes:
supported
true if the media content can be encoded at all. Otherwise, it is false.smooth
true if playback of the media will be smooth (of high quality). Otherwise it is false.powerEfficient
true if playback of the media will be power efficient. Otherwise, it is false.Browsers will report a supported media configuration as smooth and powerEfficient until stats on this device have been recorded.
All supported audio codecs are reported to be power efficient.
configuration passed to the encodingInfo() method is invalid, which may be for any of the following reasons:
contentType is not a valid codec MIME type,configuration elements.// Create media configuration to be tested
const mediaConfig = {
type: "record", // or 'transmission'
video: {
contentType: "video/webm;codecs=vp8.0", // valid content type
width: 1920, // width of the video
height: 1080, // height of the video
bitrate: 120000, // number of bits used to encode 1s of video
framerate: 48, // number of frames making up that 1s.
},
};
// check support and performance
navigator.mediaCapabilities.encodingInfo(mediaConfig).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.`);
});
{{Specifications}}
{{Compat}}