Skip to content

bug: obs-ffmpeg: WebM/VP9 recording with BGRA fails to start (upstream #13785) #310

Closed

Description

@rdoupe

Upstream OBS bug, reported by PickKali in obsproject/obs-studio#13785 (also nilankadesilva). Code unchanged in this fork.

Location

  • plugins/obs-ffmpeg/obs-ffmpeg-output.c create_video_stream(): for a BGRA output the pixel format is chosen with avcodec_find_best_pix_fmt_of_list(pix_fmts, BGRA, has_alpha=1), which picks the encoder's least-lossy listed format. FFmpeg 8 and later list gbrap for libvpx-vp9, but libvpx-vp9 only opens gbrap with strict experimental compliance ("not widely supported ... use 'yuva420p'"), so avcodec_open2 returns EINVAL.

Class

Output fails to start: a custom FFmpeg recording to WebM/VP9 with the BGRA (alpha) video format fails with "Failed to open video codec: Invalid argument".

How it is reached

Settings → Output → Recording, type Custom Output (FFmpeg), container WebM, video encoder libvpx-vp9, with Settings → Advanced → Video color format BGRA (for a transparent recording): starting the recording fails. It appears as a regression with the newer bundled FFmpeg, which lists gbrap; the ffmpeg CLI fails the same way for BGRA input to libvpx-vp9.

Reproduced with the real ffmpeg_output recording core video at BGRA through libvpx-vp9 into WebM: it fails with exactly that error.

Proposed fix and failing test

Fix: when the chosen format has alpha and the encoder rejects it with EINVAL, drop it and retry with the next-best format that still has alpha (libvpx-vp9 ends on yuva420p), logging which format was rejected. Encoders that open their first choice, non-alpha formats and other errors are unchanged, and alpha is never dropped silently: with no alpha format left it fails as before.

RED test (cmocka, test_ffmpeg_output_alpha): WebM/VP9 from BGRA must record with alpha (fails today); guards that FFV1/Matroska keeps bgra and that VP8 with its default auto-alt-ref still fails instead of losing alpha.

Activity

  1. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_ffmpeg_output_alpha (1 of 3 failing): the real ffmpeg_output recording BGRA to WebM/VP9, with FFV1 and VP8 guards.
    2. GREEN: fall back to the next alpha pixel format the encoder opens (yuva420p for libvpx-vp9).
      PR today.
  2. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    @PickKali you reported this in obsproject/obs-studio#13785, so a heads-up: it's fixed here in obs-rust by #311, merged today with a regression test.

    Cause: for a BGRA (alpha) recording OBS picks the encoder's best-matching pixel format, and newer FFmpeg lists gbrap first for libvpx-vp9, but libvpx-vp9 only opens gbrap in experimental mode, so starting failed with "Failed to open video codec: Invalid argument" (the ffmpeg command line fails the same way). Now, when an encoder rejects the chosen alpha format, OBS tries the next format that still has alpha (for VP9 that ends on yuva420p) and logs which one it used; alpha is never dropped silently. The test records BGRA to WebM/VP9 through the real FFmpeg output: before it failed with your error; now it records VP9 with alpha.

    Workaround on stock OBS: none for VP9 with alpha; FFV1 in Matroska records with alpha.

    obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR.

    If you try it, a short reply here on whether your WebM recordings work would really help.

  3. added a commit that references this issue on Oct 12, 2026
    6fd9cc9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions