linux-v4l2: Use VIDIOC_S_FMT return values in vcam #12082
+15
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When the virtual camera is opened, use the format returned by ioctl VIDIOC_S_FMT to; 1) confirm that the (YUYV) pixel format is expected, and; 2) configure the video scaling for the virtual camera.
This means that if the loopback device is constrained to a different size - then OBS studio will scale the output to the loopback device. If the pixel format of the loopback device is incorrect; the virtual camera will fail to open.
Motivation and Context
The current behaviour when a loopback device is constrained/fixed to a different size is shown in issue #12081.
There are two typical scenarios in which the loopback device will have a fixed format that could differ from OBS's output:
v4l2loopback-ctl set-caps
.Ideally; some sensible cropping might be applied if the aspect ratio is not the same between the loopback device and OBS's output, but this hasn't been implemented here. Instead, the output is 'squeezed' into the aspect ratio of the loopback device.
How Has This Been Tested?
Built on Ubuntu 24.04 with v4l2loopback 0.14.0; then tested by following similar steps for reproduction in #12081
sudo modprobe v4l2loopback video_nr=10
, thenv4l2loopback-ctl set-caps /dev/video10 "YUYV:640x360"
.ffplay /dev/video10
Here's the output scaled from 1280x720 (OBS) to 640x360 (loopback):
Types of changes
Checklist: