Skip to content

bug: linux-v4l2: frame rate truncated to int, wrong fps and restarts on every settings change (upstream #13388, #13896) #201

Closed

Description

@rdoupe

Upstream OBS bug, reported by acscd in obsproject/obs-studio#13388 and by shanefagan in obsproject/obs-studio#13896 (same root cause). acscd's upstream fix, obsproject/obs-studio#13808, is approved there but not merged. Code unchanged in this fork.

Location

plugins/linux-v4l2/v4l2-input.c:590 in v4l2_framerate_list(): the packed 64-bit (numerator, denominator) frame interval is stored in an int.

Class

Integer truncation: wrong device configuration, and a capture restart on every settings change.

How it is reached

A V4L2 Video Capture Device source with a frame rate picked in its properties.

Reproduced headlessly with the real linux-v4l2.so on a v4l2loopback device fed at 640x480, 30 fps, picking "30.00" and then changing an unrelated setting three times:

list value for "30.00" device ends up at restarts for 3 unrelated changes
master 30 1000/1 fps (the loopback driver's maximum), select timed out floods 3
with the fix 4294967326 30/1 fps 0

Proposed fix and failing test

Fix: obsproject/obs-studio#13808: store the packed value in an int64_t.

RED test (cmocka, test_v4l2_framerate), with the list entry and the framerate part of v4l2_settings_changed moved into v4l2-framerate.[ch] (behaviour unchanged):

  • picked_framerate_requests_that_interval: fails today ("picked 1/30 s per frame, setting 30 requests 0/30")
  • control_change_does_not_restart_stream: fails today
  • leave_unchanged_restarts_once: passes, guards the fix

Activity

  1. rdoupe commented on Oct 11, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_v4l2_framerate (2 of 3 failing), framerate handling moved into v4l2-framerate.[ch] with no behaviour change.
    2. GREEN: port linux-v4l: fix framerate value truncation in props obsproject/obs-studio#13808 by acscd (store the packed value in an int64_t), credited.
      PR within the hour.
  2. added a commit that references this issue on Oct 11, 2026
    ebc07f9
  3. rdoupe commented on Oct 11, 2026

    @rdoupe
    CollaboratorAuthor

    @acscd @shanefagan you reported this in obsproject/obs-studio#13388 / obsproject/obs-studio#13896, so a heads-up: it's fixed here in obs-rust by #202, which is acscd's upstream fix (obsproject/obs-studio#13808) with a regression test.

    Cause: the frame-rate list stored the packed 64-bit (numerator, denominator) interval in an int, so the picked rate was truncated (1/30 became 0/30, an infinite rate the driver clamps to its maximum), and the saved setting never matched what the device reports, so every settings change (zoom, focus, anything) restarted the capture.

    Workaround on stock OBS: leave the source's Frame Rate on "Leave Unchanged" and set the camera's rate outside OBS (e.g. v4l2-ctl --set-parm=30).

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

    If you get a chance to try it, a short reply here on whether it fixes it for you would really help, especially if it does not. Your camera model and the frame rate you pick are the useful details.

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