Since there is no answer using ffmpeg
, this is it.
Explanation
While v4l2loopback
creates virtual video devices, they are not associated with anything by default. To make them useful, you have to send streams to them via external applications such as ffmpeg
.
First load the module
$ sudo modprobe v4l2loopback exclusive_caps=1 video_nr=5 #creates `/dev/video5`
and then send your webcam's input to the virtual device.
$ ffmpeg -i /dev/video0 -f v4l2 -codec:v rawvideo -pix_fmt yuv420p /dev/video5
Now /dev/video5
works as a pseudo-webcam. Note, unlike a physical webcam, a single virtual video device can be accessed from multiple applications simultaneously. Thus, in this case, you don't have to create many virtual devices.
I wrote a script to wrap these steps: v4l2_webcam - GitHub.
Application
You can send any (raw) video to a virtual video device. This means, for example, it is possible to use a complicatedly mixed video by OBS as a camera input to a Web meeting (e.g. Skype, Zoom, etc.).
Here is a relatively complex but very practical example:
Structure
Result