git clone <repo>
cd <repo>
./start.sh- Open http://localhost:3000 on your laptop.
- Scan the QR code with your phone to join and stream video.
- Allow camera access on your phone.
- You should see your phone video mirrored on the laptop with overlays.
- After starting the project, use the
PUBLIC_URLdisplayed in the terminal. - To generate a QR code for easy phone access, run:
echo $PUBLIC_URL | qrencode -o qr.png
- Open the
qr.pngfile and scan it with your phone to join.
- WASM mode (default): All inference runs in-browser (no server GPU required).
- Server mode: Inference runs on backend (CPU-only, no GPU required).
- Switch mode:
MODE=wasm ./start.shorMODE=server ./start.sh
- To collect metrics, run the benchmarking script:
./bench/run_bench.sh --duration 30 --mode wasm
- The script will generate a
metrics.jsonfile with the following details:- Median and P95 end-to-end latency
- Processed FPS
- Uplink and downlink bandwidth (kbps)
- If phone won’t connect: ensure phone and laptop are on same network OR use
./start.sh --ngrokand use the public URL. - If overlays are misaligned: check timestamps in JSON messages.
- If CPU is high: reduce resolution or use WASM mode.
The project repository includes:
- Frontend: A Vite-based application for phone-to-browser video streaming.
- Backend (Optional): A FastAPI server for inference in server mode.
- Docker Support:
Dockerfilefor both frontend and backend.docker-compose.ymlfor local development and deployment.
- Convenience Script:
start.shto simplify starting the project with options for ngrok tunneling and mode switching.
The README.md provides:
- One-Command Start Instructions:
./start.sh
- Mode Switching:
- WASM mode (default):
MODE=wasm ./start.sh - Server mode:
MODE=server ./start.sh
- WASM mode (default):
- Phone-Join Instructions:
- Use the
PUBLIC_URLdisplayed in the terminal. - Generate a QR code for easy access:
echo $PUBLIC_URL | qrencode -o qr.png
- Scan the QR code with your phone to join.
- Use the
The metrics.json file is generated by running the benchmarking script:
./bench/run_bench.sh --duration 30 --mode wasmExample metrics:
{
"median_latency_ms": 120,
"p95_latency_ms": 180,
"fps": 15.2,
"uplink_kbps": 350,
"downlink_kbps": 400
}A 1-minute Loom video demonstrates:
- Phone-to-browser live overlay.
- Metrics output.
- Suggested improvement: Adaptive FPS based on latency and CPU load.
The report.md explains:
- Design Choices:
- WebRTC for real-time streaming.
- WASM mode for in-browser inference.
- Server mode for backend inference.
- Low-Resource Mode:
- Optimized for modest hardware (e.g., i5, 8GB RAM).
- Downscaled input (320x240) and quantized models.
- Backpressure Policy:
- Fixed-length frame queue, dropping oldest frames when overloaded.
- Processes only the latest frame for inference.
- Problem: Phones may fail to connect to the laptop due to network restrictions or lack of HTTPS.
- Symptoms: WebRTC signaling fails, or the phone cannot establish a connection.
-
Use ngrok:
- Start the project with ngrok tunneling:
./start.sh --ngrok
- Use the public HTTPS URL provided by ngrok.
- Start the project with ngrok tunneling:
-
Ensure Same Network:
- Verify that the phone and laptop are on the same Wi-Fi network.
-
Browser Flags:
- For Chrome, use the
--unsafely-treat-insecure-origin-as-secureflag:chrome --unsafely-treat-insecure-origin-as-secure=http://<laptop-ip>:3000
- For Chrome, use the
-
Alternative Browsers:
- Use Firefox, which is more permissive with local IPs.