Another Wayland Screenshare Fix

V4L2 Saves The Day!

V4L2 is video capture API for screen capturing in real time. It’s primarily used by webcams. We can exploit this API to create a dummy video device that receives the realtime video feed of the desktop screen and share the “webcam” with whatever WebRTC screenshare platform is being used. You’ll need the V4L2 loopback kernel module for this. After installing, we run the following to instantiate the dummy video device:

modprobe v4l2loopback exclusive_caps=1 card_label=VirtualVideoDevice

The new device should be at /dev/video2, which can be verified by running v4l2-ctl --list-devices. Now, all we have to do is record the screen and send the output to /dev/video2. This example will use wf-recorder, but you could realistically use other software like OBS-Studio or GNOME-Screencast. For wf-recorder, run

wf-recorder --muxer=v4l2 --codec=rawvideo --file=/dev/video2 -x yuv420p

Now you can share your screen as long as you can share your camera with your WebRTC based communication platform.