Setting up a virtual camera in Linux is fairly, virtual camera makes you play a video as a video input from a webcam, or screen share, most use cases are when you want to share multiple screens but your video chat client has limitations.
To start:
Get v4l2loopback module from here.
Note: to run the module you need kerenl-devel and kernel-headers, the package name might vary depending on your distro.
unzip the tar, open a terminal in the directory and run the following commands.
sudo make
sudo make && sudo make install
sudo depmod -aCongrats, the module is now installed, if you encounter errors, do a "sudo make clean" and retry. Note that if you do a kernel update you should rebuild this for the given kernel.
to enable the module:
Now there must be a fake webcam detected in your system, to test this run:sudo modprobe v4l2loopback exclusive_caps=1
v4l2-ctl --list-devicesif you see devices other than the system webcam that is your virtual camera. now to run a video from it you need "ffmpeg". install it from your package manager then to input a desired video to the fake webcam run:
sudo ffmpeg -re -i /path/to/Video -map 0:v -f v4l2 /dev/videoXNote: you should put the rename the videoX device as the fake dummy device name in previous list command. (for example for me /dev/video0 is my webcam and /dev/video1 is the fake camera so I rename X to 1)
To cast your screen use the following ffmpeg command:
ffmpeg -f x11grab -r 15 -s 1920x1080 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/videoX
Note: Keep the module and the ffmpeg running or the video chat app won't detect it and it will not work!
Note2: change the screen resolution to the one you are using. And it is preferred to use Xorg as your window manager!
Tested Clients for usage:
- Zoom
- Google Meet
- Jitsi
- Bluejeans
Others might work to but I haven't tested them. Comment below and I answer your issues ASAP.