Skip to content

Instantly share code, notes, and snippets.

@kiryasolod
Last active March 7, 2025 19:12
Show Gist options
  • Save kiryasolod/4f9ef434092c91030f3e654f216cc4fc to your computer and use it in GitHub Desktop.
Save kiryasolod/4f9ef434092c91030f3e654f216cc4fc to your computer and use it in GitHub Desktop.
Discord Wayland full-screen streaming in ArchLinux (tested on Hyprland)

1. Add yourself to video group

sudo usermod -aG video <username>

2. Add some variables (I'm not sure it's necessary)

export XDG_RUNTIME_DIR="/run/user/$(id -u)"

3. Install packages

sudo pacman -S wf-recorder v4l2loopback-dkms v4l2loopback-utils

4. Execute the following commands. They will create config files for modprobe service

echo "v4l2loopback" | sudo tee /etc/modules-load.d/v4l2loopback.conf

echo 'options v4l2loopback video_nr=10 card_label="Wayland Virtual Webcam"' | sudo tee /etc/modprobe.d/v4l2loopback-options.conf

The video_nr=10 is a /dev/video10 device

The Wayland Virtual Webcam is your webcam name than you will see in apps like Discord

5. Reload the modprobe service to get loopback module loaded automatically when system starts

sudo systemctl enable --now systemd-modules-load.service

6. Create a file /usr/bin/sharescreen

with the following content:

#!/bin/bash

wf-recorder --pixel-format=yuv420p -fflags +genpts --geometry="0,0 1920x1080" --filter=hflip --muxer=v4l2 --codec=rawvideo --file=/dev/video10 -t

You can adjust your geometry that you want to stream. If your watchers get a flipped picture, you can remove --filter=hflip. Beware that Discord can show a flipped picture only for you, and people who watch your stream should get normal picture. Anyway you can play with it.

Your /dev/video10 device was created by setting video_nr=10 in v4l2loopback options

7. Make your /usr/bin/sharescreen executable

sudo chmod +x /usr/bin/sharescreen

8. Then execute it! Then you can choose your Wayland Virtual Webcam in Discord and start your stream! By the way, without any resolution and framerate limits for free! You can also bind some shortcut in Sway of Hyprland. For example here is my binding in Hyprland: bind = $mainMod SHIFT, F1, exec, pkill wf-recorder || sharescreen to start and to stop streaming I use Win + Shift + F1 shortcut

@salehjg
Copy link

salehjg commented Aug 24, 2024

wf-recorder: invalid option -- 't'

@snytch
Copy link

snytch commented Nov 23, 2024

wf-recorder: invalid option -- 't'

same

@salehjg
Copy link

salehjg commented Nov 23, 2024

wf-recorder: invalid option -- 't'

same

In case you are still looking to patch the problem, just don't waste time on it. Use a 3rd party Discord client such as Vesktop. It works like a treat.

@Doctor-Slop
Copy link

wf-recorder: invalid option -- 't'

same

In case you are still looking to patch the problem, just don't waste time on it. Use a 3rd party Discord client such as Vesktop. It works like a treat.

No the fuck it doesnt.

@salehjg
Copy link

salehjg commented Jan 25, 2025

wf-recorder: invalid option -- 't'

same

In case you are still looking to patch the problem, just don't waste time on it. Use a 3rd party Discord client such as Vesktop. It works like a treat.

No the fuck it doesnt.

I use it (vesktop) everyday with wayland + gnome. Sharing the screen works perfectly.

@deusvagus
Copy link

wf-recorder: invalid option -- 't'

same

In case you are still looking to patch the problem, just don't waste time on it. Use a 3rd party Discord client such as Vesktop. It works like a treat.

No the fuck it doesnt.

If the problem is that the screenshare doesn't work in any program, you can try removing "10-bit support" from the monitor settings file, or use a tool like nwg-displays to disable it.

I've also tested wf-recorder, and the command wf-recorder --pixel-format=yuv420p -fflags +genpts --geometry="0,0 2560x1440" --filter=hflip --muxer=v4l2 --codec=rawvideo --file=/dev/video11 works fine for me. (I created /dev/video11 using sudo modprobe v4l2loopback video_nr=11 card_label="Virtual camera 11" exclusive_caps=1.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment