Skip to main content

A Python library to stream any Windows window to a virtual camera.

Project description

winlivecam

A Python library to create a virtual camera on Windows and stream the content of a selected window (by PID or title) to it.

Features

  • Windows 11 Native Support: Uses the new MFCreateVirtualCamera API for seamless integration on Windows 11.
  • Windows 10 Compatibility: Falls back to a high-performance DirectShow filter.
  • Stream any visible Windows application window to a virtual camera.
  • Select windows by Process ID (PID) or window title.
  • Leverages C++ for high-performance window capture and virtual camera implementation.
  • Easy-to-use Python API.

Installation

Prerequisites

  • Windows 10 or 11 (Windows 11 recommended for native Virtual Camera API support)
  • Python 3.7+
  • Visual Studio Build Tools (for C++ compilation, if building from source)

Install via pip (Coming Soon)

pip install winlivecam

Manual Installation (from source)

  1. Clone the repository:
    </code></pre>
    </li>
    </ol>
    <p>git clone <a href="https://github.com/yourusername/winlivecam.git">https://github.com/yourusername/winlivecam.git</a>
    cd winlivecam
    ```</p>
    <ol start="2">
    <li><strong>Build the C++ extension and virtual camera driver:</strong>
    <pre lang="bash"><code>
    

pip install pybind11 cmake pip install . ```

  1. Register the virtual camera driver: After installation, you need to register the DirectShow filter DLL. This usually requires administrator privileges.
    </code></pre>
    </li>
    </ol>
    <p>from winlivecam import LiveCam
    LiveCam.install()
    <code>To unregister:</code>python
    from winlivecam import LiveCam
    LiveCam.uninstall()
    ```</p>
    <h2>Usage</h2>
    <p>Here's a simple example of how to use <code>winlivecam</code> to stream a window by its PID:</p>
    <pre lang="python"><code>from winlivecam import LiveCam
    import time
    
    # Replace with the actual PID of the window you want to stream
    # You can find the PID using Task Manager or other tools.
    TARGET_PID = 12345 
    
    cam = LiveCam()
    
    try:
        print(f"Starting virtual camera stream for PID: {TARGET_PID}")
        cam.start_by_pid(TARGET_PID)
        print("Streaming... Press Ctrl+C to stop.")
        while True:
            time.sleep(1) # Keep the script running
    except KeyboardInterrupt:
        print("Stopping stream.")
        cam.stop()
        print("Stream stopped.")
    

    Building from Source (Development)

    If you want to contribute or modify the C++ code, follow these steps:

    1. Install CMake and Visual Studio Build Tools.
    2. Clone the repository.
    3. Build using CMake:

    mkdir build cd build cmake .. cmake --build . ``` This will build winlivecam_core.pyd (Python extension) and `vcam-filter.dll` (DirectShow filter).

    Contributing

    Contributions are welcome! Please feel free to open issues or submit pull requests.

    License

    This project is licensed under the MIT License - see the LICENSE file for details.

    Acknowledgements

    • Inspired by mycrl/vcam and OBS Virtual Camera implementations.
    • Uses pybind11 for Python-C++ interoperability.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

winlivecam-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file winlivecam-0.1.0.tar.gz.

File metadata

  • Download URL: winlivecam-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for winlivecam-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e28b65df36ba5f7cb35590f9137e27ac79533e4f9fd1367d1d726dd2106c340
MD5 345516feef7b9f370f4529446a551329
BLAKE2b-256 4a0c15b1671fb35510dc1c5f6d6e33897f014669002f0f7a22966ce124b59705

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