How to do this in Wayland

Jim azanorak at gmail.com
Wed Feb 19 21:29:11 MST 2025


On 2/19/25 18:17, Snyder, Alexander J wrote:
> On Wayland, x11grab won't work because there is no direct access to 
> the display like in Xorg. Instead, you'll need to use PipeWire and 
> wf-recorder or obs-v4l2sink.
>
> Solution Using PipeWire (wf-recorder and v4l2loopback)
>
> 1. Install required dependencies (if not already installed):
>
> sudo apt install wf-recorder v4l2loopback-utils v4l2loopback-dkms
>
>
> 2. Load the v4l2loopback module (if not already loaded):
>
> sudo modprobe v4l2loopback devices=1 video_nr=10 card_label="Virtual 
> Camera" exclusive_caps=1
>
> This creates /dev/video10, which you will use as your virtual camera.
>
>
> 3. Capture the second monitor and send it to /dev/video10:
>
> wf-recorder -o HDMI-A-1 -f - | ffmpeg -i - -f v4l2 -vcodec rawvideo 
> -pix_fmt yuv420p /dev/video10
>
> Replace HDMI-A-1 with your monitor's correct name. Find your available 
> outputs with:
>
> swaymsg -t get_outputs

I tried swaymsg and got this

$ swaymsg -t get_outputs
00:00:00.040 [swaymsg/main.c:494] Unable to retrieve socket path

I tried to find another way to get the same information.  I ended up 
trying ls /sys/class/drm and found card1-HDMI_A_1 among the contents of 
that folder.


Next I tried the wf-recorder command you said to try.  I got the 
following and Zoom didn't detect a camera.  Do I have something missing?


$ wf-recorder -o HDMI-A-1 -f - | ffmpeg -i - -f v4l2 -vcodec rawvideo 
-pix_fmt yuv420p /dev/video10
ffmpeg version 6.1.1-3ubuntu5 Copyright (c) 2000-2023 the FFmpeg developers
   built with gcc 13 (Ubuntu 13.2.0-23ubuntu3)
   configuration: --prefix=/usr --extra-version=3ubuntu5 
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu 
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl 
--disable-stripping --disable-omx --enable-gnutls --enable-libaom 
--enable-libass --enable-libbs2b --enable-libcaca --enable-libcdio 
--enable-libcodec2 --enable-libdav1d --enable-libflite 
--enable-libfontconfig --enable-libfreetype --enable-libfribidi 
--enable-libglslang --enable-libgme --enable-libgsm --enable-libharfbuzz 
--enable-libmp3lame --enable-libmysofa --enable-libopenjpeg 
--enable-libopenmpt --enable-libopus --enable-librubberband 
--enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex 
--enable-libtheora --enable-libtwolame --enable-libvidstab 
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 
--enable-libxml2 --enable-libxvid --enable-libzimg --enable-openal 
--enable-opencl --enable-opengl --disable-sndio --enable-libvpl 
--disable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 
--enable-chromaprint --enable-frei0r --enable-ladspa --enable-libbluray 
--enable-libjack --enable-libpulse --enable-librabbitmq --enable-librist 
--enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libx264 
--enable-libzmq --enable-libzvbi --enable-lv2 --enable-sdl2 
--enable-libplacebo --enable-librav1e --enable-pocketsphinx 
--enable-librsvg --enable-libjxl --enable-shared
   libavutil      58. 29.100 / 58. 29.100
   libavcodec     60. 31.102 / 60. 31.102
   libavformat    60. 16.100 / 60. 16.100
   libavdevice    60.  3.100 / 60.  3.100
   libavfilter     9. 12.100 /  9. 12.100
   libswscale      7.  5.100 /  7.  5.100
   libswresample   4. 12.100 /  4. 12.100
   libpostproc    57.  3.100 / 57.  3.100
compositor doesn't support wlr-screencopy-unstable-v1
[in#0 @ 0x639aee7d2cc0] Error opening input: Invalid data found when 
processing input
Error opening input file -.
Error opening input files: Invalid data found when processing input
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20250219/9faa11d7/attachment.htm>


More information about the PLUG-discuss mailing list