Skip to content

linux-v4l2: frame rate list truncates packed value to 32-bit int, so selected frame rate is ignored (driver falls back to max fps) #14036

Open

Description

@jrsallee

Operating System Info

Other

Other OS

Linux (Bazzite / Fedora 44), kernel 7.2.9, KDE Plasma (Wayland)

OBS Studio Version

32.2.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/WnFAT6SSKggJAjrQ

OBS Studio Crash Log URL

No response

Expected Behavior

Selecting a frame rate (e.g. 60.00) in the Video Capture Device (V4L2) properties makes OBS request that frame rate from the device.

Current Behavior

OBS ignores the selected frame rate and requests the device's fastest interval instead. With an Elgato 4K X (UVC, discrete frame intervals of 30/50/59.94/60/120/144 fps), selecting 60.00 produces:
v4l2-input: Pixelformat: NV12
v4l2-input: Framerate: 144.00 fps
The scene collection then contains "framerate": 60.

Side effects: the capture's select() timeout is computed from the bogus frame rate (5 frame periods ≈ 34.7 ms at 144 fps). When the source actually delivers 30 or 60 fps, OBS logs repeated select timed out messages. With MJPG, a timeout or bad frame shortly after start can be followed by failed to unpack jpeg or h264 / Stopped capture after 0 frames. The source then stays frozen on its last frame until it's recreated or OBS is restarted.

Steps to Reproduce

  1. Add a Video Capture Device (V4L2) source for a UVC device that reports discrete frame intervals.
  2. Choose a resolution and select a frame rate below the device maximum (e.g. 60.00).
  3. Check the log: Framerate: shows the device's maximum fps, not the selected value.

Anything else we should know?

In plugins/linux-v4l2/v4l2-input.c, v4l2_framerate_list(), discrete case (line 590 in 32.2.2):
int pack = v4l2_pack_tuple(frmival.discrete.numerator, frmival.discrete.denominator);
v4l2_pack_tuple() returns int64_t (PACK64(a, b) = a << 32 | b). Storing it in an int drops the numerator. For 1/60, PACK64(1, 60) = 4294967356 becomes 60. On load, v4l2_unpack_tuple() sees the upper 32 bits are zero and takes the legacy 16-bit path: numerator = 60 >> 16 = 0, denominator = 60. VIDIOC_S_PARM receives timeperframe = 0/60, and uvcvideo picks the shortest supported interval (144 fps).

The hard-coded list in the non-discrete branch passes *packed (int64_t) directly, so only the discrete branch is affected.

Suggested fix...in theory:
Scene collections already saved with the truncated value (numerator 0) would still request the max rate. It may be worth treating an unpacked numerator of 0 as invalid in v4l2_unpack_tuple() / v4l2_set_framerate(), either by falling back to the device default or by correcting it.

Known workaround:
With OBS closed, set the source's "framerate" in the scene collection JSON to the correctly packed value, e.g. 4294967356 for 1/60. OBS then logs Framerate: 60.00 fps and the timeouts stop. Re-selecting a frame rate in the dropdown writes the truncated value again.

Activity

  1. acscd commented on Oct 24, 2026

    @acscd

    I previously reported this in #13388. Merging PR #13808 (or making a 5-byte change) will fix it. I hope somebody addresses this soon!

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions