Skip to content

Patched fork of pyvirtualcam

Logan Crandall edited this page Apr 23, 2021 · 3 revisions

Patched fork of pyvirtualcam

How pyvirtualcam simulates a webcan.

pyvirtualcam will write frame buffers to a shared memory buffer. All applications that want to consume the virtual camera will read from that shared memory buffer.

Diagram of how pyvirtualcam uses shared memory

The problem

pyvirtualcam is unable to start or stop video while camera is in use. In addition if the shared memory buffer is already created when starting, pyvirtualcam will cause the application to exit without error. This is because pyvirtualcam will try to create a new shared buffer with the same name that already exists and the Windows API will not allow it.

The Solution

In the patched version of pyvirtualcam, it will first attempt to reacquire the previous buffer it if can find one. If it does not find one, it will then create a new shared buffer. The shared buffer is only released when it is safe to do so. This way we can start and stop the camera even when its being read by other processes without issue.

Clone this wiki locally