Skip to main content

canRenderAudioCodec()

warning

Very experimental feature - expect bugs and breaking changes at any time. Track progress on GitHub and discuss in the #web-renderer channel on Discord.

Available from v4.0.401 - Part of the @remotion/web-renderer package.

Checks if the browser supports encoding audio with the specified codec and options. Use this function to verify browser capabilities before attempting to render.

Example usage
tsx
import {canRenderAudioCodec} from '@remotion/web-renderer';
 
const canRender = await canRenderAudioCodec('aac', {
sampleRate: 44100,
numberOfChannels: 2,
bitrate: 'medium',
});
 
if (canRender) {
console.log('AAC encoding is supported!');
} else {
console.log('AAC encoding is not supported, try opus instead.');
}

Arguments

codec

string WebRendererAudioCodec

The audio codec to check support for. One of:

  • "aac" - AAC codec (widely supported, used in MP4)
  • "opus" - Opus codec (used in WebM)

options?

object CanRenderAudioCodecOptions

An optional object with the following properties:

numberOfChannels?

number

The number of audio channels (e.g., 2 for stereo).

sampleRate?

number

The audio sample rate in Hz (e.g., 44100 or 48000).

bitrate?

number | string WebRendererQuality

The target bitrate for encoding. Can be either:

  • A number representing bits per second
  • A quality preset: "very-low", "low", "medium", "high", or "very-high"

Return value

Returns Promise<boolean> - resolves to true if the browser supports encoding with the specified configuration, false otherwise.

Example: Finding a supported codec

Find supported audio codec
tsx
import {canRenderAudioCodec} from '@remotion/web-renderer';
import type {WebRendererAudioCodec} from '@remotion/web-renderer';
 
const findSupportedAudioCodec = async (): Promise<WebRendererAudioCodec | null> => {
const codecs: WebRendererAudioCodec[] = ['aac', 'opus'];
 
for (const codec of codecs) {
if (await canRenderAudioCodec(codec)) {
return codec;
}
}
 
return null;
};
 
const codec = await findSupportedAudioCodec();
console.log('Supported audio codec:', codec);

See also