This method will help in streaming a pre-recorded video as a webcam video in an ubuntu-based Linux distro.


Step 1 : Install ffmpeg and v4l-utils.

sudo apt install ffmpeg
sudo apt install v4l-utils

Step 2 : Install v4l2loopback.

git clone
cd v4l2loopback
sudo make install

(Optional step: Only if above command fails)

git clone
cd v4l2loopback
sudo apt install dkms
sudo cp -R . /usr/src/v4l2loopback-1.1
sudo dkms add -m v4l2loopback -v 1.1
sudo dkms build -m v4l2loopback -v 1.1
sudo dkms install -m v4l2loopback -v 1.1

Step 3 : Record video from any application (cheese in ubuntu) and save it in home directory with the name input.webm.

Step 4 : Enlarge the recorded video from previous step to a 1 hour video by looping it 60 times.

for i in {1..60}; do printf "file '%s'\n" input.webm >> list.txt; done
ffmpeg -f concat -i list.txt -c copy output.webm

Note: Change {1..60} as required.

Step 5 : Start the virtual webcam. (Do it every time when your system is restarted)

sudo modprobe v4l2loopback exclusive_caps=1

Step 6 : Know the path where the newly created dummy webcam is present and make a note of it.

v4l2-ctl --list-devices

Example -

v4l2-ctl --list-devices output

Step 7 : Stream

ffmpeg -re -i output.webm -map 0:v -f v4l2 /dev/video2

Note: change /dev/video2 according to what you got from step 6.

Step 8 : Change webcam setting and choose the dummy video option on any website or application.

v4l2-ctl --list-devices output


References / /