MarshalX/python-webrtc
Acerca de
Chrome's WebRTC engine, with the browser API, in Python
Creación y multimediaWhat you can do
- 🌐 The real engine. ICE, DTLS, SCTP, congestion control, jitter buffers and codecs are Chrome's own, so interop with browsers is the browsers' interop.
- 🧩 The browser API. Written against the W3C specifications and tested with the web-platform-tests the browsers use.
- 🎞️ Every modern codec. VP8, VP9, AV1, H.264 and Opus. Hardware H.264 through VideoToolbox on macOS.
- ⚡ Native media path. Packets, decoding and encoding never touch Python. You see frames, not packets.
Crecimiento de estrellas medido
- in 24h
- +1
- in 7 days
- +1
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalChrome's WebRTC engine, with the browser API, in Python.
Documentation • Quickstart • Examples • Benchmarks • PyPI
Python WebRTC binds libwebrtc M152, the engine inside Chrome, and exposes it through the W3C APIs you
already know from the browser: RTCPeerConnection, data channels, tracks, WebCodecs frames, encoded transforms and
stats. Talk to browsers, servers, SFUs and AI agents peer-to-peer, with no vendor service in between.
pip install wrtc
Coming from aiortc? Install
wrtc[aiortc], changefrom aiortctofrom webrtc.aiortc, and your code runs on Chrome's engine. See Migrating from aiortc.
If you know it in JavaScript, you know it in Python
| Browser | Python |
|---|---|
|
|
Names follow the specifications in snake_case, and the camelCase originals (createOffer) work too. Enums compare
equal to the strings of the specification, dictionaries are typed dataclasses, and everything is asyncio.
Highlights
- 🌐 The real engine. ICE, DTLS, SCTP, congestion control, jitter buffers and codecs are Chrome's own, so interop with browsers is the browsers' interop.
- 🧩 The browser API. Written against the W3C specifications and tested with the web-platform-tests the browsers use.
- 🎞️ Every modern codec. VP8, VP9, AV1, H.264 and Opus. Hardware H.264 through VideoToolbox on macOS.
- ⚡ Native media path. Packets, decoding and encoding never touch Python. You see frames, not packets.
- 🖼️ Frames in, frames out.
MediaStreamTrackProcessor,VideoTrackGeneratorandMediaStreamTrackGeneratorwith WebCodecs'VideoFrameandAudioData, piped through WHATWG Streams. - 🔐 Encoded transforms.
RTCRtpScriptTransformand end-to-end encryption with SFrame. - 🚀 Fast connection setup. WARP: DTLS 1.3, SNAP and SPED cut round trips off every new connection.
- 📦
pip installand go. Prebuilt wheels for Linux, macOS and Windows, CPython 3.9–3.15, including free-threaded 3.14t and 3.15t. Nothing else to install. - 🏷️ Typed. Full type stubs, so your editor knows every interface, dictionary and event.
How it compares
| Python WebRTC | aiortc | LiveKit SDK | GStreamer webrtcbin | |
|---|---|---|---|---|
| Engine | libwebrtc (Chrome's) | own, in Python | libwebrtc | own, in C |
| Connects peer-to-peer to any WebRTC endpoint | ✅ | ✅ | ❌ needs a LiveKit server | ✅ |
Browser API (RTCPeerConnection, createOffer, …) |
✅ | similar | ❌ rooms | ❌ GObject signals |
| Media path | native | Python | native | native |
| VP9 and AV1 | ✅ | ❌ | ✅ | ✅ |
pip install on Linux, macOS and Windows |
✅ | ✅ | ✅ | ❌ no Linux wheels |
Against aiortc, it opens connections 7.3–8.3x faster, moves 7.7–14.6x more data through a data channel and spends less CPU on audio. See the benchmarks, which also measure Pion, libdatachannel and webrtc-rs.
The full comparison, and when another library is the better choice: Choosing a Python WebRTC library.
Codecs
| Linux and Windows | macOS | |
|---|---|---|
| Video | VP8, VP9, AV1, H.264 with OpenH264 | VP8, VP9, AV1, H.264 with VideoToolbox |
| Audio | Opus, G.722, G.711 | Opus, G.722, G.711 |
No H.264 implementation is built into the package. webrtc.openh264.install() downloads Cisco's binary on the
user's device, under Cisco's patent license.
Platforms
Prebuilt wheels for CPython 3.9–3.15, and free-threaded 3.14t and 3.15t, on:
| Linux | macOS | Windows |
|---|---|---|
| x86_64 and aarch64 (glibc 2.27+, manylinux) | 13+, Intel and Apple Silicon | x64 |
Elsewhere pip builds it from sources with CMake and a C++20 compiler. See CONTRIBUTING.md.
Examples
Complete programs, ready to copy. The ones with dependencies declare them inline, so uv run needs nothing installed.
- 🤖 Voice chat with OpenAI GPT-Live: talk to the model through your microphone and speakers. No server, just an API key.
- 📺 Live stream in the terminal: watch a public Janus stream as colored characters, with the audio on your speakers.
- 🔁 Echo peer: send the received video back in grayscale.
- 💾 Recorder: write received video and audio to files.
uv run https://raw.githubusercontent.com/MarshalX/python-webrtc/main/examples/janus_streaming.py
Pipecat
Install wrtc[pipecat] and import the SmallWebRTC transport from webrtc.pipecat, and your
Pipecat bot runs on Chrome's engine, with its clients unchanged. For Pipecat's development
runner, call webrtc.pipecat.install_alias(). See Use with Pipecat and the
voice bot example.
Status
Pre-1.0: the API follows the specifications, but compatibility between versions isn't guaranteed until 1.0.0. See the changelog.
Getting help
- 📖 Documentation: quickstart, guides and the API reference.
- 🐛 Report a bug or request a feature.
- 💬 Ask a question.
Contributing
Contributions of any size are welcome. CONTRIBUTING.md covers the development setup, building from sources, releasing and updating libwebrtc.
License
Python WebRTC is published under the BSD 3-Clause License.
Explorar proyectos relacionados
Cargando…