loading

Support

IsSupported

True when the runtime exposes navigator.mediaCapabilities.decodingInfo. Broadly available, but not on every engine, so keep a fallback path that simply tries to play.

C#
@inject Bit.Butil.MediaCapabilities mediaCapabilities

var isSupported = await mediaCapabilities.IsSupported();
Live sample
support output
Results will appear here when you interact with the samples.

Will this stream play smoothly?

DecodingInfo

A full configuration in, three flags out: supported at all, smooth (no dropped frames), and power-efficient (hardware rather than CPU). Pick a rung of the ladder and see what the engine says about it - a null answer means the configuration itself was rejected as malformed.

C#
var info = await mediaCapabilities.DecodingInfo(new MediaDecodingConfiguration
{
    Type = MediaDecodingType.MediaSource,
    Video = new VideoConfiguration
    {
        ContentType = "video/mp4;codecs=avc1.42E01E",
        Width = 1920,
        Height = 1080,
        Bitrate = 5_000_000,
        Framerate = 30
    }
});

if (info is { Supported: true, Smooth: true, PowerEfficient: true })
{
    // safe to offer this rendition, even on battery
}
Live sample
Codec
Resolution
Framerate (30 fps)
How it arrives
decoding output
Results will appear here when you interact with the samples.

Encoding queries

EncodingInfo

The same three flags for encoding - what to consult before choosing a MediaRecorder container or a WebCodecs configuration. Support is thinner than for decoding: an engine that answers decoding questions may refuse this one entirely.

C#
var info = await mediaCapabilities.EncodingInfo(new MediaEncodingConfiguration
{
    Type = MediaEncodingType.Record,
    Video = new VideoConfiguration
    {
        ContentType = "video/webm;codecs=vp9",
        Width = 1280,
        Height = 720,
        Bitrate = 2_500_000,
        Framerate = 30
    }
});
Live sample
encoding output
Results will appear here when you interact with the samples.

Audio, and protected playback

DecodingInfo with Audio / KeySystemConfiguration

A query needs at least one track, and audio alone is a valid question. Adding a key-system configuration asks something different again: whether the codec plays smoothly under DRM, which is not the same as whether it plays smoothly in the clear.

C#
var audio = await mediaCapabilities.DecodingInfo(new MediaDecodingConfiguration
{
    Type = MediaDecodingType.File,
    Audio = new AudioConfiguration { ContentType = "audio/mp4;codecs=mp4a.40.2", Channels = "2", Samplerate = 48000 }
});

var drm = await mediaCapabilities.DecodingInfo(new MediaDecodingConfiguration
{
    Type = MediaDecodingType.MediaSource,
    Video = new VideoConfiguration { ContentType = "video/mp4;codecs=avc1.640028", Width = 1920, Height = 1080, Bitrate = 6_000_000, Framerate = 30 },
    KeySystemConfiguration = new MediaCapabilitiesKeySystemConfiguration
    {
        KeySystem = "com.widevine.alpha",
        InitDataType = "cenc",
        VideoRobustness = "HW_SECURE_ALL",
        VideoEncryptionScheme = "cenc"
    }
});
Live sample
audio and DRM output
Results will appear here when you interact with the samples.
Note:
Three flags, three different decisions Supported says the stream can play. Smooth says it will keep up. PowerEfficient says the work lands on dedicated hardware rather than the CPU - the difference between an hour of battery and three. A rung that is supported but neither smooth nor power-efficient is exactly the one an adaptive player should skip.
Warning:
A malformed query is answered with null, not with false The specification rejects a configuration with no codecs in its content type, or with neither a video nor an audio track, rather than reporting it as unsupported. Butil surfaces that as null - so null means "the question was wrong", and Supported = false means "the browser said no".

API reference

Member
Signature
Description
IsSupported
ValueTask<bool> IsSupported()
True when the runtime exposes navigator.mediaCapabilities.decodingInfo.
DecodingInfo
ValueTask<MediaCapabilitiesInfo?> DecodingInfo(MediaDecodingConfiguration configuration)
Whether this exact stream can be played, played smoothly, and played on hardware. Null when the configuration was rejected.
EncodingInfo
ValueTask<MediaCapabilitiesInfo?> EncodingInfo(MediaEncodingConfiguration configuration)
The same three flags for encoding - what to consult before choosing a recorder or codec configuration.
MediaDecodingConfiguration
Type, Video, Audio, KeySystemConfiguration
The query: how the media arrives, which tracks to ask about, and optionally the DRM it is protected with.
MediaEncodingConfiguration
Type, Video, Audio
The encoding query: record or webrtc, and the tracks being encoded.
VideoConfiguration
ContentType, Width, Height, Bitrate, Framerate, HasAlphaChannel, HdrMetadataType, ColorGamut, TransferFunction, ScalabilityMode, SpatialScalability
The video track. The first five are required by the specification.
AudioConfiguration
ContentType, Channels, Bitrate, Samplerate, SpatialRendering
The audio track. Only ContentType is required.
MediaCapabilitiesKeySystemConfiguration
KeySystem, InitDataType, DistinctiveIdentifier, PersistentState, SessionTypes, AudioRobustness, VideoRobustness, AudioEncryptionScheme, VideoEncryptionScheme
Asks the smoothness question about protected playback rather than clear playback.
MediaCapabilitiesInfo
Supported, Smooth, PowerEfficient, KeySystemAccessible
The answer. KeySystemAccessible is set when a key-system configuration was part of the query.
An unhandled error has occurred. Reload 🗙