Skip to main content

Send frames to a virtual camera

Project description

pyvirtualcam

pyvirtualcam sends frames to a virtual camera from Python.

Usage

import pyvirtualcam
import numpy as np

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:
        frame[:] = cam.frames_sent % 255  # grayscale animation
        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.10.1-cp310-cp310-win_amd64.whl (167.7 kB view details)

Uploaded CPython 3.10Windows x86-64

pyvirtualcam-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (140.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.10.1-cp310-cp310-macosx_10_9_x86_64.whl (258.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pyvirtualcam-0.10.1-cp39-cp39-win_amd64.whl (167.7 kB view details)

Uploaded CPython 3.9Windows x86-64

pyvirtualcam-0.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (140.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.10.1-cp39-cp39-macosx_10_9_x86_64.whl (258.6 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

pyvirtualcam-0.10.1-cp38-cp38-win_amd64.whl (167.7 kB view details)

Uploaded CPython 3.8Windows x86-64

pyvirtualcam-0.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (139.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pyvirtualcam-0.10.1-cp38-cp38-macosx_10_9_x86_64.whl (258.4 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

pyvirtualcam-0.10.1-cp37-cp37m-win_amd64.whl (167.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

pyvirtualcam-0.10.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142.3 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

pyvirtualcam-0.10.1-cp37-cp37m-macosx_10_9_x86_64.whl (257.8 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 10937dcaa8af2c99df272ebecc28b2c6a1f5518fab9f9e58aa7bd3b714cff296
MD5 fd18fac37c9130a7faf59856f644fd32
BLAKE2b-256 3f9b68d9d6159c1414ce3f466130da00e35d1facbdca49d51d772a3c18c8f43e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c80181199528e1a5ae521c81356586ac5a088be9c3a9f5eba83d9e9782ec0cd
MD5 ec86896a6fc60ae9038787cfc81a1ee2
BLAKE2b-256 ede7d0ef2a6739c3f2ad920188d59eed0856ba79c19283ff1783f616e0845c29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a1f624a5c8450b3e2fde4baf1a0c09e995e7473888312c1efffded52dcf30df8
MD5 f1b4baf4c463c967a0842f1f5c60d0a7
BLAKE2b-256 3e36b905347e1505b9e7fad12ee376b0a2257ebd19b3febfe496a54fa41c7cdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7a241ecf2015a485879a126e3a05274ad138774bbf4be3e3d43100f8dddeb806
MD5 82f00ed868029cf165079a0f5952070f
BLAKE2b-256 f756afa64331283f033117084abc64004fad3ebff3e882d59e4a862b95af575b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6e58cb55fb8d96f7139b6a3500f6b55b1b72f3d8098fc888faf804280347e95
MD5 23a49b84c28f882da33439159847fa3a
BLAKE2b-256 efd429b5b388912f796556dd02ec8c89729490410f9c194865987660099aef4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a380317c6acec31ffc5db495e64d166a36cf81c9231479e7873d9a5289ab5be2
MD5 bca6f47e497c68b01ff7eebe84085622
BLAKE2b-256 589d9fa4612d193677ac2e5d799413f6ba383998c94be5a2351f32cc8ec1e9ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 79095d4f21cf5072c2c78a6d0be3061412ff4a871db3fb1fce5fa96d1cf38e8e
MD5 ad4e365e6fcc1c0b224fc08197ed5441
BLAKE2b-256 f3f7dbec92028068e498db7f78502c0a06c815d5617a612d8779c6ea693a6f1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a8203dadee71a6a7ad7e0451db3ba16ac1f4b7fb2b56d4d47ae4ea9fccf2fc3
MD5 926830a5615b2106b826f2516a52d3b1
BLAKE2b-256 c6e10b9e8eda5080693a9d3100441366bf88d56a9d3deb4bf5215cc1398abeb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f59fa7cc573e644bac0843946b263b90d0bc9fd8affa58d84ceec36ada458d02
MD5 0d28a2b41863739371a85569ed173cef
BLAKE2b-256 637f9bd4b85fa0a746ed1e0d292574f1c9e1ed4124341842f3c37f4630ea40b1

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.10.1-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a625bb77666dfdeb4a9458dec2f1a7d3d5fbb75f60910e2ec29591c45c86d9ad
MD5 26698890bc9e18f541bcde5aecafa616
BLAKE2b-256 4b3f19ac87f91a2d90585a1958f6a20b2fb7c7b72fec9a93c6629822714dd906

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.10.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9539024b7599f8cf8092fa46e552f33446f1e4ab8ab78100145543236021884
MD5 6b2ae26f204fb179a23254547356aa37
BLAKE2b-256 f1c93359499626d5da183bb5d9825123a63aed29040c02e7b13ba1641be8f02b

See more details on using hashes here.

File details

Details for the file pyvirtualcam-0.10.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvirtualcam-0.10.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0d270f95d65d11ca5ac51b3c1dbe24af211d3dc334f7bc1b24df8c1a50a3856e
MD5 76a19a0ee7efb779966cbbecb98710eb
BLAKE2b-256 5df01260b48c717a612777dfa3d442ca9197756c40c64bfd9aa8d86c386010a7

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