A little fun with Zoom
Published 2020-12-20 on Yaroslav's weblog
Since the beginning of the Orwellian nightmare that befell upon us this year, many of us have been forced to not only fundamentally change the way that we go about our lives and interact with other people, but also to use platforms for video communications that not only are proprietary, but are also of very dubious origin and quality. Well, either that, or fail academically (for those still in university, like myself), or professionally (for those being forced to use this software at work). That, however, doesn't mean that you cannot make use of the situation and have a little fun.
Disclaimer: I am not responsible for any consequences that may result of your use of this trick. Use it at your own discretion.
In trying to find a way to share my screen on Zoom in Wayland, I thought that it might not hurt if I had a little fun in one of my "Zoom classes". After all, I was forced to install this Chinese spyware in my computer, the least I could do is have fun with it. As is known, many programs lack the ability to capture or share the screen in Wayland. I am required to share my screen from time on my remote classes, so I was thinking of a way I could do just that.
One day, a thought came to my mind. In Linux systems (as in most Unix-like
systems) everything is a file. Therefore, webcams are also a file
(/dev/video*
). So in theory, I should be able to capture my screen with the
screen capture software I normally use, and somehow redirect it to a "fake"
webcam, and from there use that fake webcam in any videoconferencing software
(e.g. Zoom) as I would my normal real webcam.
As it is most of the time, some people had already invented the solution to my
problem, and the software I was looking for, came in the form a kernel module
called v4l2loopback
. This genius piece of software does precisely what I was
thinking of, it creates a fake webcam in /dev
. However, it was only the first
part of the equation, the second part is the software that captures the screen
itself and redirects it to the fake webcam. It doesn't even have to be your
screen, it could be any video stream. After finding the solution, I decided to
kill two birds with one stone, and test it by being a troll in one of my
classes.
Some instructions
I use Artix Linux (i.e. Arch Linux sans Systemd), so the instructions that I am writing here apply for that distro. However, I am pretty sure you reproduce these instructions with small modifications in any other Linux distribution.
First we'll need some packages. The packages that are or might be of use are the following:
- v4l2loopback — the kernel module that will create the fake webcam.
- ffmpeg — (optional/recommended) if you haven't used ffmpeg yet, I recommend that you install it even if you aren't going to use it for the purposes of this post. It is a utility for working with video and audio. In this case, it will allow us to redirect video files into the fake webcam, or, if you are using X, capture your screen and redirect it to the cam.
- wf-recorder — (optional/wayland;wlroots) this is the defacto program for screen capture in Wayland compositors that are based of off wlroots. In my case, I use Sway.
So in Artix/Arch you would install them like so:
# pacman -Sy v4l2loopback-dkms ffmpeg wf-recorder
After installation we'll need to rebuild the boot image:
# mkinitcpio -p <your-kernel>
Where <your-kernel>
is the name of your linux kernel image, e.g. linux
,
linux-lts
, linux-zen
, etc.
Before using the module we'll, of course, need to reboot. However, I added a
little line to my /etc/rc.local
file, so that the fake webcam would be added
right upon system boot:
modprobe v4l2loopback card_label="Screen share" exclusive_caps=1
If you don't want it to appear after every boot, you can just execute that command as root on your terminal any time you need it. The fake webcam will disappear after a reboot. You can also remove them yourself, and add different loopback devices, for that, consult the documentation of the v4l2loopback project.
Now is when the fun can start. For the first example, showing video in the webcam, by using ffmpeg:
$ ffmpeg -i <your-video-file> -f v4l2 /dev/video<X>
The fake webcam should be the last video device if you already had your real
webcam(s) connected. So if you already had /dev/video0
and /dev/video1
, then
the loopback webcam should be /dev/video2
, unless you specified it to be
something else when loading the v4l2loopback module.
Second example, show your X11 desktop in your webcam, using ffmpeg:
$ ffmpeg -f x11grab -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video<X>
The last example, and the one that applies to my case, showing the desktop of my (wlroots-based) Wayland compositor:
$ wf-recorder -o <display-name> -x yuv420p -c rawvideo -m v4l2 -f /dev/video<X>
I also have a script in my dotfiles for easy screen recording (and now also sharing) under Sway using bemenu (dmenu for Wayland) here.
The results
If you followed the instructions up to this point, then: congratulations! Now you can do stuff like this:
Well, of course, you can be better than me and actually use it for something useful, like sharing your presentation slideshow with your peers. But where's the fun in that?
https://www.yaroslavps.com/weblog/zoom-trolling/
© 2018—2024 Yaroslav de la Peña Smirnov.