Skip to main content

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 is supported. Install an older version if you need OBS 26 / 27 support.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyvirtualcam-0.11.0-cp312-cp312-win_amd64.whl (162.4 kB view details)

Uploaded CPython 3.12Windows x86-64

pyvirtualcam-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.0-cp312-cp312-macosx_10_9_x86_64.whl (258.1 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pyvirtualcam-0.11.0-cp311-cp311-win_amd64.whl (163.5 kB view details)

Uploaded CPython 3.11Windows x86-64

pyvirtualcam-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.0-cp311-cp311-macosx_10_9_x86_64.whl (260.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pyvirtualcam-0.11.0-cp310-cp310-win_amd64.whl (161.4 kB view details)

Uploaded CPython 3.10Windows x86-64

pyvirtualcam-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl (258.9 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pyvirtualcam-0.11.0-cp39-cp39-win_amd64.whl (160.7 kB view details)

Uploaded CPython 3.9Windows x86-64

pyvirtualcam-0.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl (259.0 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

pyvirtualcam-0.11.0-cp38-cp38-win_amd64.whl (161.4 kB view details)

Uploaded CPython 3.8Windows x86-64

pyvirtualcam-0.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl (258.7 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file pyvirtualcam-0.11.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 266c4e23a10a2bb4b0553c32a81ab68a18925861d04f3081f584fcf85b06caf0
MD5 cc13bea0b6c1a9b9c2dfa3f05a6f8c81
BLAKE2b-256 ceba490f5b17c4680ae45977d81c4e0dd29772b5f23c7926072e5c5c5ff2bef7

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80cda0aede3f8ae2782a0de8cca98c9427dde9eed15abc4b1abd04555cac24e5
MD5 cf8c0eb234dec83e09a96350ea39189b
BLAKE2b-256 e2ecfbceb5a9f40a7fa90d5c293e7e74274d20ece932fb847a822852a753da75

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3bc550f97a3d43235a22cafec1490061918a5a3c2d87cda8ea67ccfbf3f71ed2
MD5 314020766096705e90d23ffbee74f0dd
BLAKE2b-256 212d35cb25e4eabaa806d01b1a5aef6e2d34a0c5407a81d736c960602626e1a0

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 628d6d080846bb21c27703e773de0ede1e5e993ef4959e62dc30062f14e5f5d4
MD5 802ade55cf3cfcf847ca59fc88438a33
BLAKE2b-256 dd47713373d924d42d4df0a2e02f036f6f48a1a33e35c92fe1efac5a4f0df5f3

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1878315604d8af4e9fc1f6cdc844f294420d8691990a3c47d08299165a95e4cc
MD5 311a5f566b092987f3c29896aef3a3ff
BLAKE2b-256 a246cfe523e5e5b8762262ea064b95ad5e9a3214ac82e25cf295b60be8e23a73

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6b203ff38e460c01767d59001faeee890df2df03a996832a58e5bf004f4b36b5
MD5 400366d8553b08e7bd4af90877e8016a
BLAKE2b-256 afe6b32fce9d9082c713ef989714b10a9825a38fa5ec75518d54feef49cd5361

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3c9ee8743695a73a3818e3d6e118b4103cb007ddfcdc29f4221cfc19b8684535
MD5 5402c7829d94c1584c2be4d710915bbe
BLAKE2b-256 a0d04c7bc3922d67fb753f7cb6de9330439942ee074042195962abdb7e8ceeb4

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 75751d3fb2739ca458c30d8b102ae2d9f37c181cb047e6d704b51ca763c8b2e6
MD5 0f73a01834a5da1f70e2abec3e6eb0b7
BLAKE2b-256 a5f082eda564710e51de6f39fe5d669ad0d661f29c6175df6f33aa8bcc1a3618

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9a0b74725a55f00b5a6089cfc8acbd703aed8e38a3c53ed7a9bde98dbebd5ab9
MD5 56d50a45597cc11cecbc5dcb87d02656
BLAKE2b-256 b8de002aac828dea8dd3c0173852c3df389348d0147b789483d83a2191d7a57c

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a507e85a18d57a2ea0b498f403e8f0943b66856b24009eaca0acfa95ed2a6dbe
MD5 b8b8e2c5dfb216dbe64d279ee1c755eb
BLAKE2b-256 60d79e308af5f4c848647b3b42b5526ead2a33073f90bc39b0f50ad8b4cae8d3

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59c4542b63fbabc0455ed4a609dce20435337703ce3ea5b8618a79bfe832e4be
MD5 55a3747e8bbc626dd6c02d3983cac1b5
BLAKE2b-256 c0b22288b498f7e195fd6420c78b67e01668b6c230258126c3d3ba94cefb57d9

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b537df2a70f30cdd4c4687b5f9071801de1a5ce5ece56b26ff42789b8860592e
MD5 73abc8f26a04988396ce8a1566c88277
BLAKE2b-256 d85842381d6fd01fff2137952b514d971b069fff25faf250a5254f0fb56efe20

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4e02a4c1a227d2c0997a1fa4e69f5adf92b025b7a43b801d61a1402d3ef40b4f
MD5 914b3d5d9c2c45eb8bc9fd3208f4ca10
BLAKE2b-256 be1731570b6ddfa293466a76c2e68e49b77e2d0954ebe170ccdff79cfb2661c4

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3dcf8b9575b1bec63a3b22ca20ae9fd05a0eb04e01b5f8763d006c89c145098
MD5 89e8e7fad58a19af6338279475807e25
BLAKE2b-256 649a789800e0409cb60925cd04cc0a1da44ce00a49e9d4a4a3ad92f741bb1cbe

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc83406060fd78f6688596e189fce73f67a920479230a5ae9b28ddb585b05dae
MD5 75c86f940bd452f46edaab322c775279
BLAKE2b-256 5410c433b3eda55f2243d976a929ee27054e30c42639a4ccdd644439339c9d2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page