Dummy webcam (v4l2, ffmpeg & filters)

It was on my todo list for weeks, ever since the COVID-19 pandemic kicked off to create a dummy webcam device on my Linux box to fool Zoom, Jitsi, Google Meet, Teams, etc.., into streaming whatever I like: videos of me paying attention when I\'m not, films, or gliched out filters. It\'s 3 simple commands around v4l2loopback and ffmpeg. I thought I would share them here.

Setup the v4l2loopback device

$ sudo modprobe v4l2loopback exclusive_caps=1

Get the device name (in my case /dev/video2)

$ v4l2-ctl --list-devices

Now the fun stuff (Examples)

Stream an mp4

$  ffmpeg -re -i matrix.mp4 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2

Glitches & Filters

$ ffmpeg -f v4l2 -framerate 60 -video_size 1280x720 -input_format mjpeg -i /dev/video0 -filter_complex "scale=w=iw/20:h=ih/20, datascope=s=1280x720:mode=color2" -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2

More ffmpeg filter examples here and here.

JBG, Thu 16 Apr 2020 02:03:34 PM CEST