Skip to content

n-92/Two-Mirrors-Helper-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Two Mirrors — Desktop Webcam Receiver

Turns a phone running Two Mirrors in Webcam (PC) mode into a regular webcam that Zoom, Teams, Meet, Discord, OBS, etc. can see.

How it works

  • Phone opens TCP 8889 and emits H.264 frames when a client connects.
  • This script reads the frames, decodes with PyAV (FFmpeg), and pushes them to the OBS Virtual Camera driver via pyvirtualcam. That driver shows up as a normal webcam system-wide on Windows.

One-time setup

  1. Install OBS Studio (https://obsproject.com/). You don't have to use its UI — we just need the Virtual Camera DirectShow filter that ships with it. On modern OBS the filter is registered at install time; you don't need to hit "Start Virtual Camera" in OBS at all.

  2. Install Python 3.10+ and the deps:

    cd desktop
    pip install -r requirements.txt
    

    av (PyAV) bundles FFmpeg on Windows — no separate FFmpeg install needed.

  3. Enable USB debugging on the phone (Settings → About → tap Build Number 7×, then Developer Options → USB debugging).

Running it

  1. Plug the phone in over USB. Make sure adb is on PATH (or use --adb-path).

  2. On the phone, launch Two MirrorsWebcam (PC) → pick a lens. It'll sit at "Waiting for PC…".

  3. On the PC:

    py twomirrors_webcam.py
    

    The script runs adb forward tcp:8889 tcp:8889 for you, connects, and starts the virtual camera. If multiple phones are plugged in, pass -s <serial> (see adb devices). You should see virtual camera active: OBS Virtual Camera and the phone status flipping to "PC connected · streaming". In Zoom / Teams / browser pick OBS Virtual Camera as the camera source.

Options

  • --host <ip> — connect directly to a phone IP (skips UDP auto-discovery). Useful when discovery can't find the phone — typically because the network blocks inter-client traffic. Pair with Tailscale (see below) if you're on a network like that.
  • --usb — single-phone USB mode. Runs adb forward tcp:8889 tcp:8889 and connects to localhost. Requires USB debugging on the phone.
  • --no-mirror — skip the horizontal flip. By default we mirror the frame so front-facing camera text reads correctly, matching how laptop webcams behave.

Tailscale mode (recommended for enterprise / uni / hotel WiFi)

UDP auto-discovery and direct TCP-over-Wi-Fi both assume the phone and PC can actually reach each other. On corporate, university, or hotel networks that's usually not true: client isolation blocks device-to-device traffic, and PC-side firewalls often drop inbound UDP on port 8890. Symptoms: the script sits at "waiting for phones…" forever, or --host <ip> can't open the TCP connection.

The fix is Tailscale — it builds an encrypted mesh between your devices that tunnels straight through whatever firewall is in the way. Each device gets a stable 100.x.x.x address that works from any network (home, uni, cellular).

  1. Install Tailscale on the PC and each phone, sign in with the same account on all.

  2. Open the Tailscale app on each phone and note its 100.x.x.x address.

  3. Run:

    py twomirrors_webcam.py --host 100.x.x.x
    

That's it — the phone is reachable by that IP as long as both devices have Tailscale running, no matter what Wi-Fi they're each on.

Multiple phones. Pass --host once per phone (or comma-separate them). The feeds are tiled into a single 1280×720 virtual camera — Zoom/Teams/etc. see one webcam that shows all angles at once:

py twomirrors_webcam.py --host 100.x.x.a --host 100.x.x.b
py twomirrors_webcam.py --host 100.x.x.a,100.x.x.b,100.x.x.c

Grid layout is automatic: 2 phones = side-by-side, 3 = two-top-one-bottom, 4 = 2×2, more = ceil(sqrt(N)) columns.

Troubleshooting

  • ModuleNotFoundError: No module named 'pyvirtualcam' — you didn't install requirements, or installed them into a different Python. Try python -m pip install ….
  • No virtual cameras found — OBS isn't installed, or its Virtual Camera filter wasn't registered. Reinstall OBS with admin rights, or run C:\Program Files\obs-studio\data\ obs-plugins\win-dshow\virtualcam-install.bat as admin.
  • Phone says "Waiting for PC…" foreveradb forward didn't run, or it ran against a different device. Re-check with adb devices and re-run with the -s flag.
  • Stutter / high latency over Wi-Fi — use USB (adb forward). Wi-Fi Direct isn't usable here because Windows doesn't join Wi-Fi Direct groups as a client.

About

Python script to use with two mirrors app for allowing webcam usage on PC.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages