A lightweight Python WebRTC streaming server-client using aiortc and OpenCV.
Project description
EasyRTC
EasyRTC is a lightweight Python-based WebRTC framework built with aiortc that allows easy peer-to-peer video and data streaming between a server and client using OpenCV and asyncio. This example demonstrates how to capture video on the server side and display it in real-time on the client side with grayscale processing.
Features
- 🎥 Simple server-side webcam streaming
- 📡 WebRTC-based peer-to-peer video connection
- 🎞️ Real-time OpenCV processing
Requirements
- Python 3.7+
aiortcopencv-pythonnumpyav
You can install the required packages with:
pip install easyrtc
Examples
camera_server.py
from easyrtc import WebRTCServer, CameraStream
import asyncio
async def main():
server = WebRTCServer("127.0.0.1", 9999)
server.add_camera_stream(CameraStream())
await server.run()
if __name__ == "__main__":
asyncio.run(main())
camera_client.py
from easyrtc import WebRTCClient
import asyncio
import cv2
async def main():
client = WebRTCClient("127.0.0.1", 9999)
await client.connect()
while True:
frame = await client.get_frame()
if frame is not None:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("WebRTC Client", gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
await client.close()
cv2.destroyAllWindows()
if __name__ == "__main__":
asyncio.run(main())
data_server.py
from easyrtc import WebRTCServer, DataStream
import asyncio
async def main():
server = WebRTCServer("127.0.0.1", 9999)
server.add_data_stream(DataStream(
message={"type": "status", "value": "running"},
interval=1.0
))
await server.run()
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easyrtc-0.0.2.tar.gz.
File metadata
- Download URL: easyrtc-0.0.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c291bce6ce3a53109816866670331a1616d04663aed322bee3142ef7425da28c
|
|
| MD5 |
be0fa19c8795c79e5c1b992acf580606
|
|
| BLAKE2b-256 |
6b50b976afea6d3b020032cdd839ce6b1a787a8bd65270523042d7eea943a899
|
File details
Details for the file easyrtc-0.0.2-py3-none-any.whl.
File metadata
- Download URL: easyrtc-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35a38cbaf09b7186ac2527f0f23c07b3cf58abad450dc6539389dce40668499e
|
|
| MD5 |
a5d565e0b213be8229079fd22d166cc2
|
|
| BLAKE2b-256 |
5bb328d6071118a5d96e783e8d8e26ee2c01cf45e7601b5ad0b64615bb481e69
|