Skip to content

fix: handle av1 VideoDecoder errors#334

Open
matthew-hre wants to merge 2 commits intosiddharthvaddem:mainfrom
matthew-hre:matthew-hre/jj-przmrvurqkow
Open

fix: handle av1 VideoDecoder errors#334
matthew-hre wants to merge 2 commits intosiddharthvaddem:mainfrom
matthew-hre:matthew-hre/jj-przmrvurqkow

Conversation

@matthew-hre
Copy link
Copy Markdown

@matthew-hre matthew-hre commented Apr 5, 2026

Description

Fix AV1 VideoDecoder error during export when recordings use AV1 in WebM containers (the default on Linux). When web-demuxer returns a bare "av01" codec string, we now parse the AV1CodecConfigurationRecord from the extradata to build the full WebCodecs-compatible codec string (e.g. "av01.0.09M.08").

Motivation

My export kept crashing 😭. Chrome/Electron's MediaRecorder writes AV1 WebM files with an AV1CodecConfigurationRecord whose version field is 127 (0xFF first byte) instead of the spec-mandated 1 (0x81). The web-demuxer library's WASM-side parser (set_av1_codec_string) strictly checks version != 1 and bails early, returning a bare "av01" string rather than the full parametrized form. VideoDecoder.configure() then rejects it with "Unknown or ambiguous codec name", making all AV1 exports fail.

extradata: FF 09 0C 00
               ↓
web-demuxer: version = 0xFF & 0x7F = 127 ≠ 1 → early return → "av01"
               ↓
VideoDecoder.configure({ codec: "av01" }) → "Unknown or ambiguous codec name"

When getDecoderConfig() returns a bare "av01", we now parse the extradata ourselves, only requiring the marker bit to be set rather than a strict version check. For the example above this produces "av01.0.09M.08" (Main profile, level 3.1, Main tier, 8-bit). Falls back to "av01.0.01M.08" if extradata is missing or too short.

Type of Change

  • New Feature
  • Bug Fix
  • Refactor / Code Cleanup
  • Documentation Update
  • Other (please specify)

Related Issue(s)

None. Discovered while packaging for NixOS.

Screenshots / Video

N/A: no UI changes. The fix is in the export pipeline (streamingDecoder.ts).

Testing

  1. Record a screen capture on Linux (records AV1 in WebM by default)
  2. Open the recording in the editor
  3. Click Export

Before fix: Export fails with "VideoDecoder Error: Unknown or ambiguous codec name"
After fix: Export completes successfully

You can verify your recording is AV1/WebM with:
ffprobe -v warning -select_streams v:0 -show_entries stream=codec_name ~/.config/openscreen/recordings/<your-recording>.webm

If you see Unknown version 127 of AV1CodecConfigurationRecord found! in the warnings, your file is affected by this bug.

Checklist

  • I have performed a self-review of my code.
  • I have added any necessary screenshots or videos.
  • I have linked related issue(s) and updated the changelog if applicable.

Summary by CodeRabbit

  • Bug Fixes
    • Improved AV1 codec detection and normalization so players now recognize generic AV1 labels and use a precise codec string when available, improving compatibility and playback reliability for AV1-encoded video.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant