{"record":{"id":"1bbf57a8c76e19ec","repo":"remotion-dev/remotion","slug":"this-browser-cannot-encode-the-vp9-video-streams-r","errorCode":null,"errorMessage":"This browser cannot encode the VP9 video streams required for video layer separation.","messagePattern":"This browser cannot encode the VP9 video streams required for video layer separation\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/separate-video-layers.ts","lineNumber":293,"sourceCode":"\t\tthrow new Error('The input video has invalid dimensions.');\n\t}\n\n\tconst [canEncodeBase, canEncodeForeground] = await Promise.all([\n\t\tcanEncodeVideo('vp9', {\n\t\t\twidth,\n\t\t\theight,\n\t\t\tquality: videoQuality,\n\t\t\talpha: 'discard',\n\t\t}),\n\t\tcanEncodeVideo('vp9', {\n\t\t\twidth,\n\t\t\theight,\n\t\t\tquality: videoQuality,\n\t\t\talpha: 'keep',\n\t\t}),\n\t]);\n\tif (!canEncodeBase || !canEncodeForeground) {\n\t\tthrow new Error(\n\t\t\t'This browser cannot encode the VP9 video streams required for video layer separation.',\n\t\t);\n\t}\n\n\treturn {videoTrack, width, height};\n};\n\nexport const separateVideoLayers = async (\n\toptions: SeparateVideoLayersOptions,\n): Promise<SeparateVideoLayersResult> => {\n\tvalidateOptions(options);\n\tthrowIfAborted(options.signal);\n\n\tconst model = options.model ?? 'modnet';\n\tconst audio = options.audio ?? 'base';\n\tconst videoQuality = resolveVideoMattingQuality(\n\t\toptions.videoBitrate ?? 'very-high',\n\t);","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/separate-video-layers.ts#L275-L311","documentation":"Before processing, the library checks with mediabunny's canEncodeVideo('vp9', ...) that the browser can encode both VP9 output streams, including one with alpha: 'keep'. If either base (opaque) or foreground (alpha) VP9 encoding is unsupported, the Error is thrown — video layer separation outputs WebM VP9 with alpha and cannot run on such browsers.","triggerScenarios":"Running separateVideoLayers in Safari (no VP9 alpha encoding via WebCodecs), older Firefox, or any browser whose WebCodecs VideoEncoder lacks VP9 support.","commonSituations":"Safari on macOS/iOS — the most common hit; embedded WebViews (Android WebView, Electron with restricted codecs); headless browsers without full WebCodecs encoder support.","solutions":["Run in a Chromium-based browser (Chrome/Edge 94+), which supports VP9 encoding with alpha via WebCodecs.","Feature-detect first with mediabunny's canEncodeVideo('vp9', {alpha: 'keep'}) and show a browser-support message instead of failing mid-process.","Avoid embedded WebViews; open the page in the full browser.","If you must support Safari, perform separation server-side instead of in-browser."],"exampleFix":"// before\nawait separateVideoLayers({src}); // throws in Safari\n// after\nif (!(await canEncodeVideo('vp9', {alpha: 'keep'}))) {\n  alert('Use Chrome or Edge for video layer separation.');\n  return;\n}\nawait separateVideoLayers({src});","handlingStrategy":"validation","validationCode":"import {canEncodeVideo} from 'mediabunny';\nif (!(await canEncodeVideo('vp9', {alpha: 'keep'}))) {\n  throw new Error('This browser cannot encode VP9 with alpha. Use Chrome or Edge.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await separateVideoLayers({src});\n} catch (e) {\n  if (e instanceof Error && e.message.includes('cannot encode the VP9')) {\n    showBrowserUnsupportedNotice();\n    return;\n  }\n  throw e;\n}","preventionTips":["Feature-detect VP9 alpha encoding at app startup and gate the feature behind it.","Recommend/require Chromium-based browsers for this feature.","Avoid embedded WebViews; offer a server-side fallback for unsupported browsers."],"tags":["mediabunny","vp9","webcodecs","browser-support","encoder"],"backgroundTag":"unsupported-platform","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}