WebCodecs API
Published
WebCodecs API — The WebCodecs API gives web apps low-level, hardware-accelerated access to encode and decode individual video frames and audio chunks via VideoEncoder, VideoDecoder, AudioEncoder, and AudioDecoder.
Browser & ecosystem support
Section titled “Browser & ecosystem support”- Legend
- Yes
- Partial
- Flag
- No
- Unknown
| Browser / Platform | Support | Versions | Confidence | Source | Notes |
|---|---|---|---|---|---|
| Chrome (Desktop) | Yes | 94 | high | source | 1 |
| Chrome (Android) | Yes | 94 | high | source | 23 |
| Edge (Desktop) | Yes | 94 | high | source | 45 |
| Firefox (Desktop) | Yes | 130 | high | source | 6 |
| Firefox (Android) | No | — | high | source | 78 |
| Safari (macOS) | Yes | 16.4 | high | source | 9 |
| Safari (iOS) | Yes | 16.4 | high | source | 1011 |
| Samsung Internet | Yes | 17.0 | high | source | 1213 |
| WebView (Android) | Yes | 94 | high | source | 1415 |
| Chrome (Desktop) | Yes | 94 | high | source | 16 |
| Chrome (Android) | Yes | 94 | high | source | 1718 |
| Edge (Desktop) | Yes | 94 | high | source | 1920 |
| Firefox (Desktop) | Yes | 130 | high | source | 21 |
| Firefox (Android) | No | — | high | source | 2223 |
| Safari (macOS) | Yes | 26 | high | source | 24 |
| Safari (iOS) | Yes | 26 | high | source | 2526 |
| Samsung Internet | Yes | 17.0 | high | source | 2728 |
| WebView (Android) | Yes | 94 | high | source | 2930 |
- Covers the `VideoDecoder` entry.
- Covers the `VideoDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome.
- Covers the `VideoDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome.
- Covers the `VideoDecoder` entry.
- Covers the `VideoDecoder` entry.
- No Firefox for Android support is recorded in browser-compat-data.
- Covers the `VideoDecoder` entry.
- Covers the `VideoDecoder` entry.
- Derived by browser-compat-data mirroring from Safari.
- Covers the `VideoDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome Android.
- Covers the `VideoDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome Android.
- Covers the `AudioDecoder` entry.
- Covers the `AudioDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome.
- Covers the `AudioDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome.
- Covers the `AudioDecoder` entry.
- Covers the `AudioDecoder` entry.
- No Firefox for Android support is recorded in browser-compat-data.
- Covers the `AudioDecoder` entry.
- Covers the `AudioDecoder` entry.
- Derived by browser-compat-data mirroring from Safari.
- Covers the `AudioDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome Android.
- Covers the `AudioDecoder` entry.
- Derived by browser-compat-data mirroring from Chrome Android.
How to use it
Section titled “How to use it”VideoDecoder takes an output callback for each decoded frame and an error callback,
then decodes chunks you feed it via decode():
function createVideoDecoder(onFrame) { const decoder = new VideoDecoder({ output: (frame) => { onFrame(frame); frame.close(); }, error: (e) => console.error(e), }); return decoder;}How to detect it at runtime
Section titled “How to detect it at runtime”Check for VideoDecoder before creating one. When it is absent, disable the
frame-by-frame feature and show that it is unavailable:
if ('VideoDecoder' in window) { enableFrameByFrameProcessing();} else { disableFrameByFrameProcessing(); showFrameByFrameUnavailableMessage();}Practical checklist
Section titled “Practical checklist”VideoFrameandAudioDataobjects reference-count their underlying media resources — callclose()on each one as soon as you are done with it. For outputVideoFrames owned by aVideoDecoder, waiting on garbage collection to reclaim them can stall further decoding.- Safari shipped
VideoDecodersupport starting in Safari 16.4; feature-detect the specific interface you need rather than assuming other WebCodecs interfaces ship on the same schedule. - Firefox added
VideoDecoderon desktop in Firefox 130, but that addition did not extend to Firefox for Android, soVideoDecoderis undefined there. - An unsupported or invalid codec string does not make
configure()reject a promise —configure()closes the decoder and delivers aNotSupportedErrorto itserrorcallback, or throws a synchronousTypeErrorif the config fails validation. Always pass the fully-qualified codec string your source media actually uses.
Where to go next
Section titled “Where to go next”For the full reference (worker usage and the fully-specified codec-string requirement), see WebCodecs: low-level, hardware-accelerated audio and video encoding.
See also WebGPU.
← Back to the Compatibility explorer.