Skip to content

bug: linux-v4l2: a frame rate saved by OBS up to 32.2 still runs the camera at its fastest rate (upstream #14036, follow-up of #201) #1117

Closed

Description

@rdoupe

Upstream OBS bug, reported by jrsallee in obsproject/obs-studio#14036 (open, no upstream PR). With an Elgato 4K X (discrete intervals 30/50/59.94/60/120/144 fps), picking 60.00 in a Video Capture Device (V4L2) source logs Framerate: 144.00 fps. The source then floods select timed out, and with MJPG it can stop at Stopped capture after 0 frames and freeze until it is recreated.

The cause in the report (the framerate list stored the packed 64-bit interval through an int) is fixed in this fork since #202 (#201, acscd's obsproject/obs-studio#13808). In 0.1.0-beta.20261014, picking 60.00 requests 1/60 s.

What is still broken is the second half of the report: scene collections saved before that fix still hold the truncated value. That covers everyone coming from stock OBS up to 32.2.2, and obs-rust before #202. In the reporter's words: "Scene collections already saved with the truncated value (numerator 0) would still request the max rate."

Location

Class

Wrong device configuration from a saved setting, plus a capture restart on every settings change. No crash.

Reproduced in 0.1.0-beta.20261014

The released AppImage (built from 9e2325e), headless: private Xvfb and D-Bus, fresh HOME, --multi. An LD_PRELOAD stand-in for libv4l2 answers for one camera with the reporter's intervals (30, 50, 59.94 = 1001/60000, 60, 120, 144 fps). Its VIDIOC_S_PARM picks the nearest interval the way uvcvideo does (0/x is the shortest) and logs each request. No real device is opened. The scene collection holds the V4L2 source with the saved "framerate" below. After loading it, one unrelated settings change is made over obs-websocket (Brightness).

Saved "framerate" Picked as Release: S_PARM request, device runs Release: restarts on the unrelated change This branch
60 (truncated, OBS ≤ 32.2) 60.00 0/60, 144 fps 1 1/60, 60 fps; stored as 4294967356; 0 restarts
60000 (truncated) 59.94 0/60000, 144 fps 1 1001/60000, 59.94 fps; stored as 4299262323296; 0 restarts
65566 (1 << 16 | 30, old 16-bit tuple) 30.00 1/30, 30 fps 1 1/30; stored as 4294967326; 0 restarts
4294967346 (packed 1/50, control) 50.00 1/50, 50 fps 0 same
picked "60.00" from the list (control, #202) 60.00 1/60, 60 fps 0 same

The release's own list already offers packed values (60.00 = 4294967356). So only saved values are affected, and they stay wrong until the user opens Properties and picks the rate again.

Proposed fix

When the device opens, map a saved value back to the device's interval it was picked from. The lookup uses the discrete intervals of the selected format and size, and v4l2_update() stores the result:

  • a truncated value (= the interval's denominator) becomes that interval: 60 → 1/60, 60000 → 1001/60000;
  • an old 16-bit tuple that matches an interval is stored in the 64-bit form the device reports back;
  • a value that names no rate (0/x s per frame) and matches no interval becomes "Leave Unchanged", not the driver's fastest rate. So does a denominator that several intervals share (a driver that does not reduce its fractions);
  • packed values, "Leave Unchanged", and a source whose device is missing are left as they are.

The reporter suggested this follow-up ("treating an unpacked numerator of 0 as invalid ... either by falling back to the device default or by correcting it"). This corrects it where the device lists the interval, and falls back to the device's rate otherwise.

RED test: test_v4l2_framerate also runs the real v4l2-input.c against a fake libv4l2 with the reporter's intervals. 6 of 11 cases fail today:

  • truncated 1/60 and 1001/60000 run the camera at 144 fps (2 end-to-end cases, 1 unit case);
  • an unmatched truncated value is sent as 0/25 s per frame (1 end-to-end, 1 unit);
  • an old 16-bit tuple is not stored in the device's form (1 unit).

Activity

  1. rdoupe commented on Oct 16, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    This is the part of upstream #14036 that our #202 (#201) left open. #202 fixed what the frame rate list stores. Scene collections saved before it still hold the truncated value.

    1. RED: test_v4l2_framerate also runs the real v4l2-input.c against a fake libv4l2 with the reporter's intervals (30/50/59.94/60/120/144 fps, uvcvideo-style S_PARM). A source saved with 60 or 60000 must run at 1/60 or 1001/60000 and store that interval, with no restart on an unrelated change. An unmatched truncated value must not be sent as 0/x, and an old 16-bit tuple must be stored in the device's form. Today 6 of 11 cases fail.
    2. GREEN: when the device opens, map a saved value to the device's interval it came from. If nothing matches and the value names no rate, use "Leave Unchanged". Store the result in the settings.
    3. RED and GREEN in both lanes, full ctest in both lanes, then the released AppImage with the stand-in camera and saved scene collections again, on the fixed build.
  2. added
    claimed
    on Oct 16, 2026
  3. rdoupe commented on Oct 16, 2026

    @rdoupe
    CollaboratorAuthor

    @jrsallee you reported this in obsproject/obs-studio#14036: picking 60.00 for a V4L2 Video Capture Device ran the Elgato 4K X at 144 fps. Heads-up that both halves are fixed here in obs-rust. Frame rates picked from the list are stored correctly since #202 (acscd's upstream fix, obsproject/obs-studio#13808). #1118, merged today with a regression test, handles the scene collections that were already saved with the truncated value, as you suggested in the report.

    Cause: the saved "framerate": 60 is what's left of 1/60 after the truncation. It unpacks as 0/60 s per frame, so uvcvideo picks its shortest interval. It also never matches the interval the device reports back, so every settings change restarted the capture. Now, when the camera opens, a saved value is mapped back to the device's interval it came from: 60 → 1/60, 60000 → 1001/60000 (59.94). The result is written to the scene collection. A value that matches nothing and names no rate becomes "Leave Unchanged" instead of the fastest rate. In our release, a source saved with 60 ran at 144 fps and restarted on an unrelated change. With the fix it runs at 60 fps, stores 4294967356 (your workaround value), and does not restart. We used a stand-in for your camera's frame intervals, not real hardware.

    Workaround on stock OBS: yours (set the packed value, e.g. 4294967356 for 1/60, in the scene collection with OBS closed).

    It will be in the next obs-rust daily release after 0.1.0-beta.20261014: 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 with your existing scene collection, a reply here on whether the log now says Framerate: 60.00 fps would really help.

  4. jrsallee commented on Oct 17, 2026

    @jrsallee
  5. zackees commented on Oct 17, 2026

    @zackees
    Member

    Thanks @jrsallee. You're right, the daily release has been held since 0.1.0-beta.20261014: the Windows packaging check is blocking it (#1225). The fix will be in the first daily after that clears; no need to check before then.

  6. jrsallee commented on Oct 18, 2026

    @jrsallee

    Tested obs-rust 0.1.0-beta.20261018 (Linux AppImage, Fedora/Bazzite, kernel 7.2.9) with a fresh config and a copy of my scene collection with the truncated values put back: Elgato 4K X "framerate": 60 (NV12 2560x1440) and Logitech BRIO "framerate": 30 (MJPG 3840x2160).

    • The log shows Framerate: 60.00 fps for the 4K X, and v4l2-ctl --get-parm reports 60/1 (stock OBS ran it at 144). The BRIO shows 30.00 / 30/1.
    • Toggling Use Buffering on the 4K X did not restart the capture.
    • After saving, the collection holds "framerate": 4294967356 for the 4K X and 4294967326 for the BRIO.

    All three behaviors confirmed. Thanks for the fix!

  7. rdoupe commented on Oct 18, 2026

    @rdoupe
    CollaboratorAuthor

    Thank you for testing this so thoroughly. Checking v4l2-ctl --get-parm and the saved values against the real cameras is exactly the confirmation we needed. Glad the 4K X runs at 60 now.

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