You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: linux-v4l2: virtual camera output distorted on a loopback device with a fixed format (upstream #12081) #212
plugins/linux-v4l2/v4l2-output.c in try_connect(): the format VIDIOC_S_FMT returns is ignored (line 192). The video conversion is set to the OBS output size (lines 201-205) and each frame is written as width*height*2 bytes of that size (frame_size at :156, written in virtual_video at :309).
Start the virtual camera on a v4l2loopback device whose format is fixed (v4l2loopback-ctl set-caps, or keep_format=1) at a size other than the OBS output size. The device answers S_FMT with its own size, but OBS still writes frames of the output size: at 1280x720 into a 640x480 device, each 1280-pixel row fills two 640-pixel rows and the bottom half never arrives. Viewers see a distorted, interleaved picture.
Reproduced headlessly with the real linux-v4l2 plugin and a temporary loopback device fixed to YUYV 640x480, checking every pixel pair of a four-colour quadrant pattern read back through the device: master fails (top-left 10800/21600 match with green rows interleaved, bottom quadrants 0/21600); an unfixed device passes.
Proposed fix and failing test
Fix (obsproject/obs-studio#12082): take the scaling size and frame size from the format S_FMT returned, and skip a device that doesn't keep YUYV. The frame size stays width*height*2 (the packed YUY2 data OBS hands over) rather than the PR's bytesperline*height, so a driver that leaves bytesperline at 0 doesn't get 0-byte writes; for v4l2loopback the two are equal.
RED test (cmocka, test_vcam_format), with the decision moved into vcam-format.[ch] (vcam_format_negotiate(), behaviour unchanged): 3 of 4 fail today (fixed_smaller_device_gets_frames_of_its_size, fixed_larger_device_gets_frames_of_its_size, device_fixed_to_other_pixel_format_is_refused). With the fix all 4 pass, and the quadrant check passes with the device fixed to 640x480, 640x360 and 1920x1080, and unfixed.
Two small differences from #12082: the frame size stays width*height*2 rather than bytesperline*height, so a driver that leaves bytesperline at 0 doesn't get 0-byte writes, and master's ioctl order is kept. Checked end to end against v4l2loopback 0.15.4 fixed to 640x480, 640x360 and 1920x1080 with a colour-quadrant pattern read back through the device.
obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR. If you spot anything off in the port, a reply here would help.
Activity
rdoupe commentedon Oct 11, 2026
Claiming: this issue.
test_vcam_format(3 of 4 failing), format negotiation moved intovcam-format.[ch]with no behaviour change.PR within the hour.
test/cmocka: Add RED virtual camera format negotiation tests
linux-v4l2: Write virtual camera frames in the size the device kept
rdoupe commentedon Oct 11, 2026
@stephematician you reported this in obsproject/obs-studio#12081, so a heads-up: your fix from obsproject/obs-studio#12082 is merged here in obs-rust by #213 (credited as co-author), with a regression test.
Two small differences from #12082: the frame size stays
width*height*2rather thanbytesperline*height, so a driver that leavesbytesperlineat 0 doesn't get 0-byte writes, and master's ioctl order is kept. Checked end to end against v4l2loopback 0.15.4 fixed to 640x480, 640x360 and 1920x1080 with a colour-quadrant pattern read back through the device.obs-rust is an AI-assisted fork of OBS; on Arch it's
obs-studio-rust-gitin the AUR. If you spot anything off in the port, a reply here would help.