Need help with pyfakewebcam?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

215 Stars 48 Forks GNU Lesser General Public License v3.0 35 Commits 13 Opened issues


A library for writing RGB frames to a fake webcam device on Linux!

Services available


Need anything else?

Contributors list

# 304,453
35 commits


An API for writing RGB frames to a fake webcam device on Linux!

Compatible with Python2.7 and Python3.x

Author: John Emmons Email: [email protected]

Disclaimer: I wrote this project when I was a university student. I now employed full time so I don't have time to keep things update or add new features :(. Please feel free to fork!


# use pip to get the latest stable release
pip install pyfakewebcam

use git to install the latest version

git clone cd pyfakewebcam python install


# python
pip install numpy


apt-get install v4l2loopback-utils

linux (optional)

apt-get install python-opencv # 10x performance improvement if installed (see below) apt-get install ffmpeg # useful for debugging


When I run the

script (640x360 resolution) on an Intel i7-3520M (2.9GHz, turbos to 3.6 GHz), the time to schedule a single frame is ~3 milliseconds (with opencv installed). You can use this library without installing opencv, but it is almost 10x slower; time to schedule a frame without opencv is ~26 milliseconds (RGB to YUV conversion done with numpy operations).

If your goal is to run at 30Hz (or slower) and ~26 milliseconds of delay is acceptable in your application, then opencv may not be necessary.


Insert the v4l2loopback kernel module.

modprobe v4l2loopback devices=2 # will create two fake webcam devices

Example code.

# see in the examples dir
import time
import pyfakewebcam
import numpy as np

blue = np.zeros((480,640,3), dtype=np.uint8) blue[:,:,2] = 255

red = np.zeros((480,640,3), dtype=np.uint8) red[:,:,0] = 255

camera = pyfakewebcam.FakeWebcam('/dev/video1', 640, 480)

while True:



Run the following command to see the output of the fake webcam.

ffplay /dev/video1

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.