Skip to content

bug: obs-websocket: GetSourceScreenshot labels jpg screenshots image/jpg (upstream obsproject/obs-websocket#1298) #523

Closed
obs-rust/obs-websocket
#6

Description

@rdoupe

Upstream obs-websocket bug, reported by cmack in obsproject/obs-websocket#1298 (OBS 30.1.2 on Linux, obs-websocket 5.4.2): GetSourceScreenshot with imageFormat: "jpg" returns a data URL labeled image/jpg, which is not a MIME type; with "jpeg" it is labeled image/jpeg. Two upstream PRs are open and unmerged: obsproject/obs-websocket#1337 (andrewsoncha, Qt's MIME database) and obsproject/obs-websocket#1354 (iibaranov-IG, jpg only). The bug is in this fork too.

Location

  • src/requesthandler/RequestHandler_Sources.cpp GetSourceScreenshot (line 230) builds the URL as "data:image/%1;base64," with the requested format name. The format names are Qt image writer names (GetVersion lists them as supportedImageFormats), which are file extensions. Only jpeg, png and bmp happen to equal their MIME subtype.

Class

Wrong output. The screenshot works, but its data URL carries a MIME type that does not exist.

How it is reached

Any client that asks for jpg (the more common spelling), jfif, ppm, pgm, pbm, ico, cur, xbm or xpm, then uses the URL as is (an <img src>, a download, a check on the type). SaveSourceScreenshot writes a file and is not affected.

Reproduced in the current release

AppImage 33.0.0-beta6-799, headless over obs-websocket, GetSourceScreenshot of the default scene at 64 px wide. GetVersion lists bmp, cur, ico, jfif, jpeg, jpg, pbm, pgm, png, ppm, xbm and xpm.

imageFormat URL prefix today Registered type
jpg data:image/jpg image/jpeg
jpeg data:image/jpeg image/jpeg
png data:image/png image/png
bmp data:image/bmp image/bmp
ppm data:image/ppm image/x-portable-pixmap

Proposed fix and failing test

Fix (in the obs-rust/obs-websocket fork, then a submodule update here): move the label into a helper, Utils::ImageFormat::MimeType(), that maps the writer format names to their registered MIME types (jpg, jpeg and jfif to image/jpeg; ico, cur, pbm, pgm, ppm, xbm, xpm, tif, tiff and svg to theirs) and keeps image/ plus the name otherwise. This is a fixed table and not Qt's MIME database (the approach in obsproject/obs-websocket#1337) because the database is read from the system's shared-mime-info: without it, every lookup answers application/octet-stream, and jpg would still come out wrong.

RED test (cmocka, test_ws_image_mime). It builds the plugin's helper on its own (no libobs, no Qt, no display) and checks:

  • jpg, jfif: image/jpeg;
  • ppm: image/x-portable-pixmap;
  • ico: image/vnd.microsoft.icon;
  • guard: jpeg, png and bmp stay image/jpeg, image/png and image/bmp.

Today 4 of 5 fail in both libobs lanes. The guard passes.

Activity

  1. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_ws_image_mime (5 cases) builds obs-websocket's screenshot MIME helper: jpg and jfif come out as image/jpg and image/jfif instead of image/jpeg, and ppm and ico are mislabeled too; a guard checks jpeg, png and bmp. 4 of 5 fail today.
    2. GREEN: the helper maps the image writer's format names to their registered MIME types (obs-rust/obs-websocket fork), and the submodule here moves to it.
      PR today.
  2. added
    claimed
    on Oct 13, 2026
  3. added 2 commits that reference this issue on Oct 13, 2026
    61338b1
    73f060f
  4. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    @cmack you reported this in obsproject/obs-websocket#1298 (GetSourceScreenshot with imageFormat jpg returns a data:image/jpg URL, which isn't a valid MIME type), so a heads-up: it's fixed here in obs-rust (obs-rust/obs-websocket#6, moved into OBS by #652), with a regression test.

    Cause: the label was "image/" plus the requested format name, but those names are Qt image writer names, which are file extensions, so jpg became image/jpg and ppm became image/ppm. The format names are now mapped to their registered MIME types with a fixed table: jpg and jfif give image/jpeg, ppm gives image/x-portable-pixmap, and so on, while png, bmp and jpeg are unchanged. A fixed table rather than Qt's MIME database, because that database depends on the system's shared-mime-info and answers application/octet-stream without it. In the obs-rust release jpg gave data:image/jpg; the regression test checks every format the writer offers.

    Workaround on stock OBS: request jpeg instead of jpg, which was already labelled correctly.

    It will be in the next obs-rust daily release after 0.1.0-beta.20261013: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's obs-studio-rust-git in the AUR). obs-rust is an AI-assisted fork of OBS.

    If you get a chance to try it, a reply here on whether your client now gets image/jpeg would really help.

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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions