- Load the v4l2loopback kernel module:
sudo depmod -a
sudo modprobe v4l2loopback devices=1 max_buffers=2 exclusive_caps=1 card_label="VirtualCam"
You can do this persistently by creating a config file like video.conf in /etc/modprobe.d/ with the following in it:
options v4l2loopback devices=1 max_buffers=2 exclusive_caps=1 card_label="VirtualCam"
- Check the devices that v4l2 detects:
v4l2-ctl --list-devices
---
Dummy video device (0x0000) (platform:v4l2loopback-000):
/dev/video2
T2 Webcam: T2 Webcam (usb-0000:0b:00.3-2):
/dev/video0
/dev/video1
- Check the format and resolution that is supported:
ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0
---
[video4linux2,v4l2] Compressed: mjpeg : Motion-JPEG: 1920x1080 640x480 1280x720 320x240 1024x768 1280x1024 160x120 576x1024 800x600
[video4linux2,v4l2] Raw : yuyv422: YUYV 4:2:2 : 640x480 1280x720 320x240 1024x768 1280x1024 160x120 576x1024 800x600
In this case, 1920x1080 is the highest resolution supported, and the type is mjpeg.
4. Use ffmpeg and magic to pipe the video stream to the loopback stream, editing the command to suit your devices, resolutiona nd format:
ffmpeg -hide_banner -f v4l2 -input_format mjpeg -video_size 1920x1080 -i /dev/video0 -vf format=yuyv422 -f v4l2 /dev/video2