The MediaCapabilities.encodingInfo() method, part of the MediaCapabilities interface of the Media Capabilities API, returns a promise with the tested media configuration's capabilities information. This contains the three boolean properties supported, smooth, and powerefficient, which describe how compatible the device is with the type of media.
encodingInfo(configuration)
A Promise fulfilling with an object containing three Boolean attributes:
supported -
true if the media content can be decoded 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.
const mediaConfig = {
type: "record",
video: {
contentType: "video/webm;codecs=vp8.0",
width: 1920,
height: 1080,
bitrate: 120000,
framerate: 48,
},
};
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.`);
});