Skip to content

Instantly share code, notes, and snippets.

@docPhil99
Last active February 9, 2023 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docPhil99/4eae7ccb3f6acbac4e770460df22412a to your computer and use it in GitHub Desktop.
Save docPhil99/4eae7ccb3f6acbac4e770460df22412a to your computer and use it in GitHub Desktop.
How to pass video to a dummy webcam.
  1. Start the v4l2loopback module:
sudo modprobe v4l2loopback \
      devices=1 exclusive_caps=1 video_nr=5 card_label="Dummy Camera"
  1. I have a short test video call Speed1.avi, this can be played streamed to /dev/video5 with ffmpeg -re -stream_loop -1 -i Speed1.avi -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video5
    • The -re -stream_loop -1 loops the video for ever.
  2. Linux will now think th at /dev/video5 is a webcam and other apps such as zoom will play nicely with it.

This example plays back the video from a BBC test stream

Add audio

This doesn't work yet!

  1. Load the alsa loopback module sudo modprobe snd_aloop
  2. This creates two devices, one for capture, the other for play back. You can see them via aplay -L
  3. ffmpeg -re -i London.mkv -map 0:v -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video5 -map 0:a -f alsa hw:2,1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment