Skip to content

FR - Add pipewire video source(s) in place of v4l2 #4507

Description

@pallaswept

Is your feature request related to a problem? Please describe.
scrcpy currently can use v4l2loopback devices as virtual cameras to display the screen and share it to other applications. It works as expected.

This is somewhat limited as it means the device must have a fixed resolution, so it is not possible to rotate the display, for example.

Additionally, and worse, v42loopback clients (all webcam apps, chrome browser, firefox* etc) have an issue here, where applications which expect a webcam as input often filter by devices which only have output capabilities, and not capture capabilities. Accordingly, v4l2loopback has an option exclusive_caps,which makes the virtual device's capabilities advertise exclusively as a capture device, until it is fed input (eg by scrcpy) and then the device changes its capabilities to an output device, so that it will be recognised as a webcam by the client applications.

There is presently a bug in pipewire which means that feature cannot be used. I have reported that bug to the pipewire developers, however they are not in a rush to fix it, as they consider it a fix for an obsolete method - their opinion is that v4l2loopback devices should no longer be necessary at all, as applications (such as scrcpy) can provide a native pipewire source, which can then be consumed by clients. To quote the pipewire dev on this matter:

the ideal scenario is that [the application, scrcpy in this case] creates a pipewire source node, the browser creates a pipewire capture stream and wireplumber just links them together... no V4L2 involved.

Other developers appear to agree - Firefox already has support for consumption of webcam video from pipewire sources (media.webrtc.camera.allow-pipewire), chrome has it in development versions and it will be released soon (https://bugs.chromium.org/p/webrtc/issues/detail?id=13177), webcamoid supports pipewire sources, cheese will use pipewire in future.... and for legacy applications, there is pw-v4l2 provided by pipewire, which works with most webcam apps already, here's a gnome developer's blog where he uses the tool to wrap the cheese webcam app

So, while it would be good if pipewire is fixed up so that it doesn't have problems with v4l2loopback, the future of these things appears to be that applications providing video streams, such as scrcpy, do so by means of a native pipewire source - and it comes with the additional bonus of allowing us to rotate the android screen, so that would be nice. Perhaps we would even be able to provide both screen and camera sources?

Describe the solution you'd like
Provide a native pipewire source to output video from scrcpy, in place of v4l2loopback.

Describe alternatives you've considered
No alternatives that I am aware of.

Additional context
I think I covered it all, but please let me know if there's any further info you require.

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