Skip to content

Wayland screencasting

Tools

wf-recorder

Usage:

wf-recorder --muxer=v4l2 --codec=rawvideo --file=/dev/video2 -x yuv420p
  • Can select and display stream in chromium
  • Can't select stream in firefox
  • Can select and display stream on mozilla webrtc gum page

but it only shows external monitor

wlstreamer

https://github.com/b12f/wlstreamer

Issues:

Install:

 cd ~/projects/wayland/wlstreamer
 cargo install --path . --root ~/.local

Load v4l2loopback kernel module (now auto loaded during boot):

sudo modprobe v4l2loopback exclusive_caps=1 card_label=WfRecorder

See which video device the loopback module claimes:

v4l2-ctl --list-devices

Share particular screen:

wlstreamer --not-screen DP-3 -o /dev/video0

With autofocus (beware of above bug!):

wlstreamer -o /dev/video2

Mon2Cam

https://github.com/ShayBox/Mon2Cam

  • Typescript (requires deno runtime)

Other video loopback solutions

  • https://gist.github.com/progandy/bff675311aa2c3b777a37abe81aa4b4d
  • https://gitlab.com/jamedjo/gnome-dbus-emulation-wlr

Fake screensharing using video loopback

https://wiki.archlinux.org/index.php/Screen_capture#Via_a_virtual_webcam_video_feed

Best solution so far!

screenshare.sh

And then use chromium instead of firefox (see more details below)

Native Screensharing

xdg-desktop-portal-wlr

Issues

Browser notes

https://github.com/emersion/xdg-desktop-portal-wlr/wiki/Screencast-Compatibility

Firefox

https://developer.mozilla.org/de/docs/Mozilla/Developer_guide/Build_Anweisungen/Simple_Firefox_build https://firefox-source-docs.mozilla.org/setup/linux_build.html#lets-build-firefox

  • Mozilla webrtc gum page cuts the borders of the fake screencast video stream - but the same stream displays fine in chromium (88).
  • In jitsi the image is also cropped, and has a very bad resolution → Use chromium for now

Chromium

Ubuntu snap uses X11, not wayland

https://bugs.chromium.org/p/chromium/issues/detail?id=682122 https://fhackts.wordpress.com/2019/07/08/enabling-webrtc-desktop-sharing-under-wayland/

The only solution is to use wf-recorder (see below).

run chrome in wayland mode:

chrome --enable-features=UseOzonePlatform --ozone-platform=wayland

Screencast tools

Jitsi

Issues with fake loopback video screencast:

Server tools

Screego

screen sharing for developers

Not sure if it works with wayland .. ?

Build xdg-desktop-portal and xdg-desktop-portal-wlr

xdg-desktop-portal

Build:

cd ~/project/wayland/xdg-desktop-portal
sudo apt install libjson-glib-dev libportal-dev libgeoclue-2-dev libfuse-dev
./autogen.sh
make
sudo make install

/usr/local/libexec/xdg-desktop-portal

xdg-desktop-portal-wlr

Build:

cd ~/project/wayland/xdg-desktop-portal-wlr
meson build
ninja -C build
sudo ninja -C build install

/usr/local/libexec/xdg-desktop-portal-wlr

Test (run all cmds in different terminals to watch the output):

systemctl --user stop xdg-desktop-portal-wlr.service
systemctl --user stop xdg-desktop-portal.service
systemctl --user stop xdg-desktop-portal-gtk.service
ps aux | grep xdg-des

/usr/local/libexec/xdg-desktop-portal-wlr -l DEBUG
/usr/local/libexec/xdg-desktop-portal-gtk --verbose -r
/usr/local/libexec/xdg-desktop-portal --verbose -r
journalctl -f