Skip to main content

Send frames to a virtual camera

Project description

pyvirtualcam

NOTE: This package is a work-in-progress. No support is provided, use at own risk.

Usage

import pyvirtualcam
import numpy as np

with pyvirtualcam.Camera(width=1280, height=720, fps=30) as cam:
    while True:
        frame = np.zeros((cam.height, cam.width, 4), np.uint8) # RGBA
        frame[:,:,:3] = cam.frames_sent % 255 # grayscale animation
        frame[:,:,3] = 255
        cam.send(frame)
        cam.sleep_until_next_frame()

Installation

This package is Windows-only for now. Binary wheels are provided on PyPI. Check out pyfakewebcam for something that works on Linux.

pip install pyvirtualcam

The package uses obs-virtual-cam which has to be installed separately. Note that the obs-virtual-cam installer assumes an OBS Studio installation and will fail otherwise. You can also download the obs-virtual-cam zip package from https://github.com/CatxFish/obs-virtual-cam/releases without installing OBS Studio. After unzipping, from an admin command prompt, run:

regsvr32 /n /i:1 "obs-virtualcam\bin\32bit\obs-virtualsource.dll"
regsvr32 /n /i:1 "obs-virtualcam\bin\64bit\obs-virtualsource.dll"

To uninstall, run:

regsvr32 /u "obs-virtualcam\bin\32bit\obs-virtualsource.dll"
regsvr32 /u "obs-virtualcam\bin\64bit\obs-virtualsource.dll"

Contributions

The most useful contributions would be to add support for macOS or Linux.

Similar to Windows, it may be possible in macOS to piggyback on https://github.com/johnboiles/obs-mac-virtualcam.

For Linux, it seems like https://github.com/umlaeute/v4l2loopback is the right dependency. Code from https://github.com/CatxFish/obs-v4l2sink may be useful as inspiration on how to send frames to the loopback device. Also, there is https://github.com/jremmons/pyfakewebcam which may be a good candidate.

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.3.1-cp39-cp39-win_amd64.whl (62.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyvirtualcam-0.3.1-cp38-cp38-win_amd64.whl (62.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyvirtualcam-0.3.1-cp37-cp37m-win_amd64.whl (62.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyvirtualcam-0.3.1-cp36-cp36m-win_amd64.whl (62.8 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

Supported by

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