Skip to content

Commit a9c13f5

Browse files
authored
Update README on upcoming camera support (#26)
1 parent 43ecd64 commit a9c13f5

File tree

1 file changed

+42
-20
lines changed

1 file changed

+42
-20
lines changed

README.md

+42-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pyvirtualcam
22

3-
NOTE: This package is a work-in-progress. No support is provided, use at own risk.
3+
pyvirtualcam sends frames to a virtual camera from Python.
44

55
## Usage
66

@@ -9,38 +9,60 @@ import pyvirtualcam
99
import numpy as np
1010

1111
with pyvirtualcam.Camera(width=1280, height=720, fps=20) as cam:
12-
frame = np.zeros((cam.height, cam.width, 4), np.uint8) # RGBA
13-
frame[:, :, 3] = 255
12+
print(f'Using virtual camera: {cam.device}')
13+
frame = np.zeros((cam.height, cam.width, 3), np.uint8) # RGB
1414
while True:
15-
frame[:, :, :3] = cam.frames_sent % 255 # grayscale animation
15+
frame[:] = cam.frames_sent % 255 # grayscale animation
1616
cam.send(frame)
1717
cam.sleep_until_next_frame()
1818
```
1919

20+
For more examples, check out the [`samples/`](samples) folder.
21+
2022
## Installation
2123

22-
This package is Windows-only for now. Binary wheels are provided on PyPI.
23-
Check out [pyfakewebcam](https://github.com/jremmons/pyfakewebcam) for something that works on Linux.
24+
This package works on Windows, macOS, and Linux. Install it from PyPI with:
2425

2526
```sh
2627
pip install pyvirtualcam
2728
```
2829

29-
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 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:
30-
```
31-
regsvr32 /n /i:1 "obs-virtualcam\bin\32bit\obs-virtualsource.dll"
32-
regsvr32 /n /i:1 "obs-virtualcam\bin\64bit\obs-virtualsource.dll"
33-
```
34-
To uninstall, run:
35-
```
36-
regsvr32 /u "obs-virtualcam\bin\32bit\obs-virtualsource.dll"
37-
regsvr32 /u "obs-virtualcam\bin\64bit\obs-virtualsource.dll"
38-
```
30+
pyvirtualcam relies on existing virtual cameras which have to be installed first. See the next section for details.
31+
32+
## Supported virtual cameras
33+
34+
### Windows: OBS
35+
36+
[OBS](https://obsproject.com/) includes a built-in virtual camera for Windows (since 26.0).
37+
38+
To use the OBS virtual camera, simply [install OBS](https://obsproject.com/).
3939

40-
## Contributions
40+
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.
4141

42-
The most useful contributions would be to add support for macOS or Linux.
42+
### macOS: OBS
43+
44+
[OBS](https://obsproject.com/) includes a built-in virtual camera for macOS (since 26.1).
45+
46+
To use the OBS virtual camera, follow these one-time setup steps:
47+
- [Install OBS](https://obsproject.com/).
48+
- Start OBS.
49+
- Click "Start Virtual Camera" (bottom right), then "Stop Virtual Camera".
50+
- Close OBS.
51+
52+
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.
53+
54+
### Linux: v4l2loopback
55+
56+
pyvirtualcam uses [v4l2loopback](https://github.com/umlaeute/v4l2loopback) virtual cameras on Linux.
57+
58+
To create a v4l2loopback virtual camera on Ubuntu, run the following:
59+
60+
```sh
61+
sudo apt install v4l2loopback-dkms
62+
sudo modprobe v4l2loopback devices=1
63+
```
4364

44-
Similar to Windows, it may be possible in macOS to piggyback on https://github.com/johnboiles/obs-mac-virtualcam.
65+
For further information, see the [v4l2loopback documentation](https://github.com/umlaeute/v4l2loopback).
4566

46-
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.
67+
pyvirtualcam uses the first available v4l2loopback virtual camera it finds.
68+
The camera device name can be accessed with `cam.device`.

0 commit comments

Comments
 (0)