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 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


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

pyvirtualcam-0.11.1-cp312-cp312-win_amd64.whl (162.5 kB view details)

Uploaded CPython 3.12Windows x86-64

pyvirtualcam-0.11.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (224.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyvirtualcam-0.11.1-cp312-cp312-macosx_10_9_x86_64.whl (258.2 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pyvirtualcam-0.11.1-cp311-cp311-win_amd64.whl (163.6 kB view details)

Uploaded CPython 3.11Windows x86-64

pyvirtualcam-0.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.1-cp311-cp311-macosx_11_0_arm64.whl (226.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyvirtualcam-0.11.1-cp311-cp311-macosx_10_9_x86_64.whl (260.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pyvirtualcam-0.11.1-cp310-cp310-win_amd64.whl (161.5 kB view details)

Uploaded CPython 3.10Windows x86-64

pyvirtualcam-0.11.1-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.1-cp310-cp310-macosx_11_0_arm64.whl (224.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyvirtualcam-0.11.1-cp310-cp310-macosx_10_9_x86_64.whl (259.0 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pyvirtualcam-0.11.1-cp39-cp39-win_amd64.whl (160.8 kB view details)

Uploaded CPython 3.9Windows x86-64

pyvirtualcam-0.11.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.1-cp39-cp39-macosx_10_9_x86_64.whl (259.2 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

pyvirtualcam-0.11.1-cp38-cp38-win_amd64.whl (161.5 kB view details)

Uploaded CPython 3.8Windows x86-64

pyvirtualcam-0.11.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.11.1-cp38-cp38-macosx_10_9_x86_64.whl (258.9 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 33369930327ab83a9a637f561011feff9280f2d14aa9e306e7870e57472eaaef
MD5 7fb2c98bc9ab6e1b25237f9de2b0e83e
BLAKE2b-256 33d1691ebc2872ab1973925e4ec97c416acdb3df0a62fd16d6fbbba267a2c16f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87791638e308b07bf612464c200fb49e71efbc1347feba762711b300ac53ec91
MD5 0d1f20c3268a2f3da0bd79a1dc3ebca8
BLAKE2b-256 6a866aa0b320ac3bbd6cb6000f39de86e32714019a561be7a6edb79a49e55f5f

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63b4dd02bc0885067d590d06e03042b1a4237939e48a84f12fc2c170afeb2af8
MD5 cfd05a3ae02a2e57723fa4d9877464fc
BLAKE2b-256 5ab9efa22dd6231cca67b8369d41bad72bb1e6f67be25022f2596ff5bea061ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5fe999ef554129886fffffafc385020610c25ff577f37fc36128036a6bc69a72
MD5 a75aeb1cb048e492423572cfc329c140
BLAKE2b-256 cf62d693e5f289a16bba7b7896346c77dbae03e43f0f169b9e2cdfe27a237791

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 55d7de9cae396fae6a4ac35d318d971a9b0144faa2f0bb678f59dfc935571e79
MD5 e238ee18129a2226b0f1083ce6acdf09
BLAKE2b-256 087f47ea70174b9d199c44ef42585c1a9f132cd30ce688717cee9e860ced1887

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cbb0aaefc5112ac0eb0f1125b3979387f0da02d3f21ada5c70b15ae5b4719cf2
MD5 2688a6ffa0a206a171f3dda35a4caae9
BLAKE2b-256 4eb725d4c47cc2dbc63ca0f13bee968ec5cf3aa06514ff5511810539dabeda81

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e01711354b75f89313f0c7794736dde72e34f7f0c1934f27149a193e753d7c62
MD5 193b67ca80ffdfcece874a8a1fdac4c9
BLAKE2b-256 e44071ad5595d92ea7e0961b8baea826ed399028047ae076efc08a0cda8f6fbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7cab6032e72de5a8346ad9b9f8d10f5d7cf8e5fce1535b5c98d21a25852a4c31
MD5 64b2c03adb74a1f455c2e83531c62879
BLAKE2b-256 ac3d36abfb8366eb937166953dd476d8c5a777031f1313599f4d086a1a900cea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2ff726f963bd91de77587c0c44b628d887986a5d490193ae7101e54061205eaf
MD5 00e514d72c157a5b5f29a02d04cf8767
BLAKE2b-256 24182f893ef93e0c339bb3c1aff42221d6a36cf02bfa4b5e53ba8de836eb759e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fceb0d2f6c1c8e0527d3e26ac849ab8407c60351b2044c7f1db5f5f3c9f5b972
MD5 9ee0b4a42de56acbffdaae17791948f4
BLAKE2b-256 6c771023025097d878798ec2298f08e22a47b0edb8b2c75a71ae1e448a51d3dd

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.11.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cda11de8fb25dbeca06307ebe033778998e1b44161edbf139674a44331c1dabd
MD5 d738dd3830d71ed4cc01a28c1dc9dafd
BLAKE2b-256 ce703b37156ccf97716937b6539da27a50dbf657d4c0205005d6c4c70d75a62f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ab7d18aee940bbdff34e9b943fb489ba824d75485060df90d9d0c41fe7485f29
MD5 5e2e7fa69ef15129dbc9c64107cf009e
BLAKE2b-256 a6239e910a138aac2162135443c46324f452b5e4815248b5a2ffc8a449451cf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 66356f18c72549f1752f983407d989a617782439542035beb20793a105c3c8bf
MD5 3f03dd75db82f02035bccd4f2cda562e
BLAKE2b-256 d266a38e07126e1a562ee69856c2b75e884abb04e86a5955aeffe9c01efafc65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61bf099e00e17d6c098134443b7291be7d93df6790c67217f2ae46556690f83c
MD5 ca8fe50ceccf43262fbbdbd4e3f5ff79
BLAKE2b-256 ec06b11f3ff4657860be085a4299c08308c156c0eb819ebd3a9bc793f4635900

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0bbacd5b09c333a4c29609f2838f4ad1f11f265872459a405e6ea422af5e2d91
MD5 6548737aa39e40a7a1e53ba7b86a608c
BLAKE2b-256 00ca5c543a04fa5b2345e44a481d3055e34bfaddc02fdd8b082d2e1d2d0934d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6ca7e6f306b2ffd4a0d3792089c5ba827737893f3ae8afcebc4f59264cf24844
MD5 aeae7e52d28e3cd69da84af1d3742a28
BLAKE2b-256 389aa98f6311ca65eca881ed228ded216b374ed1b47be34547eb49a92c8d0035

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a599c66c37ff3b0c21626294a367571ff582f99e0cf7012c89ac2ea5c969614d
MD5 bfd532a04cab0b93a854cf318e243801
BLAKE2b-256 fb75e33ff77c41cc71dea256c68a1fe8ce11e848f16aca6f0a51eb3fdb6fdca4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.11.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f7437e545cf4fd604bafa53969be14cac24ced43f329aaa9dc3631e7fac7308e
MD5 dced03361359443272729443d965c05a
BLAKE2b-256 3ea521d0dde3725f0a52d795026e4550cf5adfa7c7bf119c7878de626d1983a9

See more details on using hashes here.

Supported by

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