Send frames to a virtual camera
Project description
pyvirtualcam
pyvirtualcam sends frames to a virtual camera from Python.
Usage
import colorsys
import numpy as np
import pyvirtualcam
with pyvirtualcam.Camera(width=1280, height=720, fps=20) as cam:
print(f'Using virtual camera: {cam.device}')
frame = np.zeros((cam.height, cam.width, 3), np.uint8) # RGB
while True:
h, s, v = (cam.frames_sent % 100) / 100, 1.0, 1.0
r, g, b = colorsys.hsv_to_rgb(h, s, v)
frame[:] = (r * 255, g * 255, b * 255)
cam.send(frame)
cam.sleep_until_next_frame()
pyvirtualcam uses the first available virtual camera it finds (see later section).
For more examples, including using different pixel formats like BGR, or selecting a specific camera device, check out the examples/
folder.
See also the API Documentation.
Installation
This package works on Windows, macOS, and Linux. Install it from PyPI with:
pip install pyvirtualcam
pyvirtualcam relies on existing virtual cameras which have to be installed first. See the next section for details.
Supported virtual cameras
Windows: OBS
OBS includes a built-in virtual camera for Windows (since 26.0).
To use the OBS virtual camera, simply install OBS.
Note that OBS provides a single camera instance only, so it is not possible to send frames from Python to the built-in OBS virtual camera, capture the camera in OBS, mix it with other content, and output it again to OBS' built-in virtual camera. To achieve such a workflow, use another virtual camera from Python (like Unity Capture) so that OBS' built-in virtual camera is free for use in OBS.
Windows: Unity Capture
Unity Capture provides a virtual camera originally meant for streaming Unity games. Compared to most other virtual cameras it supports RGBA frames (frames with transparency) which in turn can be captured in OBS for further processing.
To use the Unity Capture virtual camera, follow the installation instructions on the project site.
macOS: OBS
OBS includes a built-in virtual camera for macOS (since 26.1).
NOTE: Starting with pyvirtualcam 0.10, only OBS 28 or higher is supported. Install an older version if you need OBS 26 / 27 support.
HELP WANTED: pyvirtualcam requires code updates to run on macOS 14 and higher. If you own a Mac, consider contributing: https://github.com/letmaik/pyvirtualcam/issues/111#issuecomment-1763398540.
To use the OBS virtual camera, follow these one-time setup steps:
- Install OBS.
- Start OBS.
- Click "Start Virtual Camera" (bottom right), then "Stop Virtual Camera".
- Close OBS.
Note that OBS provides a single camera instance only, so it is not possible to send frames from Python, capture the camera in OBS, mix it with other content, and output it again as virtual camera.
Linux: v4l2loopback
pyvirtualcam uses v4l2loopback virtual cameras on Linux.
To create a v4l2loopback virtual camera on Ubuntu, run the following:
sudo apt install v4l2loopback-dkms
sudo modprobe v4l2loopback devices=1
For further information, see the v4l2loopback documentation.
Build from source
Linux/macOS
git clone https://github.com/letmaik/pyvirtualcam --recursive
cd pyvirtualcam
pip install .
Windows
These instructions are experimental and support is not provided for them. Typically, there should be no need to build manually since wheels are hosted on PyPI.
You need to have Visual Studio installed to build pyvirtualcam.
In a PowerShell window:
$env:USE_CONDA = '1'
$env:PYTHON_VERSION = '3.7'
$env:PYTHON_ARCH = '64'
$env:NUMPY_VERSION = '1.14'
git clone https://github.com/letmaik/pyvirtualcam --recursive
cd pyvirtualcam
powershell .github/scripts/build-windows.ps1
The above will download all build dependencies (including a Python installation)
and is fully configured through the four environment variables.
Set USE_CONDA = '0'
to build within an existing Python environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pyvirtualcam-0.12.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e42386b79af13f5d6a4e65546c1f072ea4941a83b5a8306afe34cd05ea0251 |
|
MD5 | 3e861261bf10657d58e564a0e172489a |
|
BLAKE2b-256 | 5d307a3edd8db254c0277ccf2b8a89235abd634e33f0e564ed0cf8a5b88d59c5 |
Hashes for pyvirtualcam-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7a206a8fb8ccbc537a4f514cb7e5e5ecd64fb136b23e0402f42f899fea1b8b3 |
|
MD5 | 43b9f21388b91334cc149060ad3c7ce7 |
|
BLAKE2b-256 | 98c79194351fcfd3fe44e184f461d12b647fff80270797da633778a7d6b5299f |
Hashes for pyvirtualcam-0.12.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac395a12baa6ac6a77eb218ad46d27b0cd4e747189441eba1e8ffd02d05f27be |
|
MD5 | 1fb455d9374ac72bc51c327d7c072ae8 |
|
BLAKE2b-256 | 3b731b40eeeabedd0f2d59f01610004a5c501032138a6b7501438d97056dd367 |
Hashes for pyvirtualcam-0.12.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccdc303b7e92e5acff53896ad45e25805cd00e589234d03c3ee4e8d244cfb57a |
|
MD5 | dd2d4be53a7e68405916d24761b425c9 |
|
BLAKE2b-256 | 20eaf601ad3c05c99e7a3fe04de8d77310f1c80506b9d5ef3ecbfefb42ceaf3a |
Hashes for pyvirtualcam-0.12.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29f2ef4d82b392f06b086eb231da8c1e9307e7b45524631a7492b0984f695cbf |
|
MD5 | 5ca3c0f4db39753a937850bc52a9ba72 |
|
BLAKE2b-256 | 416adc404ad9fe093c36e7223b8d57ca215cd83f2d90ef19c76fe018dd6a77fa |
Hashes for pyvirtualcam-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f138f3c4e336730c632800721d488a96558b3515883753cc55893a66090fc45 |
|
MD5 | b633afa37759b69818f7618ad246359a |
|
BLAKE2b-256 | 36796c1115d2d1ffd7962d088f0e576af67d3673c66bc0bea94c96102d497de8 |
Hashes for pyvirtualcam-0.12.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9a274b995b158a46f8a0c48dd558856faadde1130658088fb154de14fb9da7 |
|
MD5 | b9a8f2603032bd6dc143e2a8c4eb7925 |
|
BLAKE2b-256 | b5fa31473f1b69fc801a11f02974004e5cd2e4e3cac91949e9b05e40908d6f29 |
Hashes for pyvirtualcam-0.12.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9642397b3ccd62e5ed047cbbec54905872883ae27a35b7b00fe82a96f1104b58 |
|
MD5 | 7efc734c43fe199740462f8e48b411af |
|
BLAKE2b-256 | afb4f41455ae18e269d937ad75132ddebcbba9a2d7499c2fcb1955b2b4f7ee5b |
Hashes for pyvirtualcam-0.12.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 226e878628536136eeae597987bdcf08504b1c2647fd77475cdb7b1e4150e9fd |
|
MD5 | 295a2a151e931f0a1ae162ac7a8f95c2 |
|
BLAKE2b-256 | c9879dc4e532ab9a5f0f8265098507052435ffec3455bbc9b0a74be239824ed7 |
Hashes for pyvirtualcam-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d82c9cc177099962bcefa8f5cadb4fe7635353fb824f3b6641d70f46dd2cf545 |
|
MD5 | d1ed6c56f36bd697fb1e8bee9ce7c90b |
|
BLAKE2b-256 | 4adc2970291cffbc1766c7370a81111f10d3d3782602828650e0c70e57d31373 |
Hashes for pyvirtualcam-0.12.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7af216fa5a499726ea8aae6b8e074293bb1b67d935087860e3bc5d46b0a90240 |
|
MD5 | a24344441f4433ca50153e09e8c7f02d |
|
BLAKE2b-256 | b8428a519326ce232a4e92ad495b4f8fbd4a0e71ca3456370a241e964c3e4a82 |
Hashes for pyvirtualcam-0.12.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d93e88a99016fdeaf4514517308ddbfa7a54fd98b0c81502946e5d2e92f701a |
|
MD5 | 6a3212299e44aac350e46b336573681e |
|
BLAKE2b-256 | db95d0285eb85f251350a2feecd9c58a0730c6eaedc965bcf790c65f2f84e7eb |
Hashes for pyvirtualcam-0.12.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc5bc4c0fa152dfe0483489190ea222c864788499ced2460882d280fd1d2514c |
|
MD5 | 8fa96cdb5f942a01459932f23ab318c6 |
|
BLAKE2b-256 | 8bdca02198bab547eee849775cb3d9fedfcd53a79f9f7357efde2fd6523d12e6 |
Hashes for pyvirtualcam-0.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3566addf0aede2ac9d9fd2f7d2f31120c396383424c19dcf6642bc3c3a122786 |
|
MD5 | 4d3f0ecc22a98fb1ac1eb52add4a1374 |
|
BLAKE2b-256 | ac1a28efc1268d164c16a55faa2b66b1660979167b5b96b5ee90296de2dde464 |
Hashes for pyvirtualcam-0.12.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ae251a3a5ba209dcfc044514e30dde1b13c70265a540d454f16b08cf19947b1 |
|
MD5 | 467959600048c365fbd54ff525dc0a8c |
|
BLAKE2b-256 | cb7f1530628b461d0da6385ebf3dd9a698c51f0b28672f56bf0b953f3a07a54f |