Skip to content

Commit 5ef5835

Browse files
committed
readme: add sample & contributions section
1 parent a703e89 commit 5ef5835

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

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

5+
## Usage
6+
7+
```py
8+
import pyvirtualcam
9+
import numpy as np
10+
11+
with pyvirtualcam.Camera(width=1280, height=720, fps=30) as cam:
12+
while True:
13+
frame = np.zeros((cam.height, cam.width, 4), np.uint8) # RGBA
14+
frame[:,:,:3] = cam.frames_sent % 255 # grayscale animation
15+
frame[:,:,3] = 255
16+
cam.send(frame)
17+
cam.sleep_until_next_frame()
18+
```
19+
520
## Installation
621

722
This package is Windows-only for now. Binary wheels are provided on PyPI.
@@ -11,3 +26,11 @@ pip install pyvirtualcam
1126
```
1227

1328
The package uses [obs-virtual-cam](https://github.com/Fenrirthviti/obs-virtual-cam/releases) 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 and extract the obs-virtual-cam zip package directly without installing OBS Studio. After unzipping, simply run `regsvr32 /n /i:1 "obs-virtualcam\bin\32bit\obs-virtualsource.dll"` from an elevated command prompt to install the virtual camera device. Use `regsvr32 /u "obs-virtualcam\bin\32bit\obs-virtualsource.dll"` to uninstall it again.
29+
30+
## Contributions
31+
32+
The most useful contributions would be to add support for macOS or Linux.
33+
34+
Similar to Windows, it may be possible in macOS to piggyback on https://github.com/johnboiles/obs-mac-virtualcam.
35+
36+
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.

samples/simple.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This script is the sample from the README.
2+
3+
import pyvirtualcam
4+
import numpy as np
5+
6+
with pyvirtualcam.Camera(width=1280, height=720, fps=20, print_fps=True) as cam:
7+
while True:
8+
frame = np.zeros((cam.height, cam.width, 4), np.uint8) # RGBA
9+
frame[:,:,:3] = cam.frames_sent % 255 # grayscale animation
10+
frame[:,:,3] = 255
11+
cam.send(frame)
12+
cam.sleep_until_next_frame()

0 commit comments

Comments
 (0)