Skip to main content

canRenderMediaOnWeb()v4.0.403

Part of the @remotion/web-renderer package.

Checks if a render can be performed with the given configuration before actually attempting it. This is useful for providing feedback to users about browser compatibility and configuration issues.

Example usage
import {canRenderMediaOnWeb} from '@remotion/web-renderer'; const result = await canRenderMediaOnWeb({ container: 'mp4', videoCodec: 'h264', width: 1920, height: 1080, }); if (!result.canRender) { for (const issue of result.issues) { console.error(issue.message); } } else { console.log('Ready to render!'); console.log('Video codec:', result.resolvedVideoCodec); console.log('Audio codec:', result.resolvedAudioCodec); }

Arguments​

An object with the following properties:

width​

number - required

The width of the video in pixels.

height​

number - required

The height of the video in pixels.

scale?v4.0.530​

number — default 1

Scales width and height before checking encoder support. Pass the composition dimensions and the same scale used for renderMediaOnWeb(), not already-scaled output dimensions.

For H.264, H.265, and AV1, the scaled dimensions are automatically adjusted down to even values when necessary, using the same calculation as the render.

container?​

string WebRendererContainer

The container format. Default is "mp4".

videoCodec?​

string WebRendererVideoCodec

The video codec to use. Default depends on the container:

  • For mp4, mkv and mov containers: "h264"
  • For webm container: "vp8"
  • For audio-only containers (wav, mp3, aac, ogg, flac): no video is encoded

audioCodec?​

string | null WebRendererAudioCodec

The audio codec to use. Default depends on the container:

  • For mp4, mkv, mov and aac containers: "aac"
  • For webm and ogg containers: "opus"
  • For wav container: "pcm-s16"
  • For mp3 container: "mp3"
  • For flac container: "flac"

transparent?​

boolean

Whether the video should have an alpha channel. Default is false.

Only the "webm" and "mkv" containers support transparency. Only the "vp8" and "vp9" codecs support transparency.

muted?​

boolean

If true, audio codec checks are skipped. Default is false.

videoBitrate?​

number | string | Quality WebRendererQuality

The video bitrate. Can be a number (bits per second) or a quality preset: "very-low", "low", "medium", "high", "very-high".

Default is "medium".

Since v4.0.535, you can also pass a Mediabunny Quality instance. Pass the same value to renderMediaOnWeb() later on as well.

audioBitrate?​

number | string WebRendererQuality

The audio bitrate. Can be a number (bits per second) or a quality preset: "very-low", "low", "medium", "high", "very-high".

Default is "medium".

outputTarget?​

string | null WebRendererOutputTarget

The output target to use for rendering. Can be:

  • "web-fs": Write the output to a temporary file in the Origin Private File System
  • "arraybuffer": Keep the output in memory as an ArrayBuffer
  • null: Auto-detect based on browser support (default)

If "web-fs" is requested but not supported by the browser, an output-target-unsupported error will be returned.

Return value​

Returns a Promise that resolves to an object with the following properties:

canRender​

boolean

true if the render can proceed, false if there are blocking issues.

issues​

CanRenderIssue[]

An array of issues found during the check. Each issue has:

type​

The type of issue (see Issue types below).

message​

A human-readable description of the issue.

severity​

Either "error" (blocking) or "warning" (non-blocking, e.g. fallback was used).

resolvedVideoCodec​

string | null WebRendererVideoCodec

The video codec that will be used for rendering. null for audio-only containers.

resolvedAudioCodec​

string | null WebRendererAudioCodec

The audio codec that will be used for rendering. This may differ from the requested codec if a fallback was applied. null if muted is true.

resolvedOutputTarget​

WebRendererOutputTarget

The output target that will be used. See renderMediaOnWeb() outputTarget for details.

Issue types​

The following issue types may be returned:

TypeDescription
webcodecs-unavailableWebCodecs API is not available in this browser
container-codec-mismatchThe video codec is not supported for the selected container
invalid-dimensionsH.264 and H.265 require width and height to be multiples of 2
video-codec-unsupportedThe browser cannot encode the selected video codec
audio-codec-unsupportedThe browser cannot encode the selected audio codec
transparent-video-unsupportedTransparency requires VP8 or VP9 codec
webgl-unsupportedWebGL is required for 3D CSS transforms
output-target-unsupportedThe requested output target is not supported by this browser

Compatibility​

BrowsersEnvironments
Chrome
Firefox
Safari

See also​