Setting Up a Virtual Webcam on Linux
I like coding, now it is become my job.
I was testing a web app that involves taking pictures. Once again, my attached webcam wasn't working, and I didn't bother to check this minor issue. Just as 42 is the answer to everything, so is v4l2loopback.
First, let's summon the video device out of thin air:
sudo modprobe v4l2loopback
Check this extensive documentation[archive] for details on the arguments you can use. A newly created video device is now available. In my case, it is at /dev/video3.
Now, see how ffmpeg takes input from testrc and then writes it to /dev/video3.
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 -f v4l2 /dev/video3

Similarly, we can use ffplay to show the video.
ffplay /dev/video3

At my workplace, I used ffmpeg and gstreamer to deliver real-time video feeds to our customers. This information might be available online, but it's scattered. While this post serves as my personal note, I hope it will also be useful for you. Ciao!
