isVideoEncoderSupported static method

Future<bool> isVideoEncoderSupported(
  1. String codecString, {
  2. int width = 1280,
  3. int height = 720,
})

Returns true if a VideoEncoder can be configured with codecString at the given width × height.

Uses VideoEncoder.isConfigSupported() — an async call to the browser. Returns false if hasVideoEncoder is false or on any error.

Example codec strings: 'avc1.42E01E' (H.264 Baseline 3.0), 'vp09.00.10.08' (VP9), 'av01.0.04M.08' (AV1).

Implementation

static Future<bool> isVideoEncoderSupported(
  String codecString, {
  int width = 1280,
  int height = 720,
}) async {
  if (!hasVideoEncoder) return false;
  try {
    final support = await web.VideoEncoder.isConfigSupported(
      web.VideoEncoderConfig(
        codec: codecString,
        width: width,
        height: height,
      ),
    ).toDart;
    return support.supported;
  } catch (_) {
    return false;
  }
}