---
title: "vuer.webrtc"
section: "Python API"
order: 33
description: "Python API reference for vuer.webrtc"
---

# vuer.webrtc

WebRTC streaming support for Vuer.

Provides BGRArrayVideoStreamTrack, WebRTCStream, and WebRTCStreamManager
for hosting WebRTC video streams on Vuer's existing aiohttp server.

Requires: pip install vuer[webrtc]

## serve_debug_page

```python
async def serve_debug_page(request)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L20)

Serve the WebRTC debug page (standalone, no manager required).

## WebRTCStream

```python
class WebRTCStream
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L132)

A single WebRTC stream that can serve video to multiple peers.

Two usage modes:
- High-level: omit track, use push_frame(bgr_numpy) to send frames.
- Low-level: provide a custom track, frames come from the track itself.

## WebRTCStream.__init__

```python
def __init__(self, stream_id, vuer, track=None, codec='H264', max_bitrate=None, max_framerate=None, resolution=None)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L140)

Args:
    stream_id: Unique identifier for the stream.
    vuer: The Vuer server instance.
    track: Optional custom MediaStreamTrack. If None, creates an
           internal track and enables push_frame().
    codec: Preferred codec ("H264" or "VP8"). Default "H264".
    max_bitrate: Maximum bitrate in bps (e.g. 2_000_000 for 2 Mbps).
                 None means encoder default.
    max_framerate: Maximum frames per second (e.g. 15, 30).
                   None means no limit.
    resolution: Tuple of (width, height) for the black fallback frame
                when no frames are being pushed. Default (640, 480).

## WebRTCStream.ready

```python
def ready(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L186)

Whether the stream's event loop has been set (server is running).

## WebRTCStream.wait_ready_sync

```python
def wait_ready_sync(self, timeout=10)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L190)

Block the current thread until the stream is ready.

Args:
    timeout: Maximum seconds to wait. Raises TimeoutError if exceeded.

## WebRTCStream.push_frame

```python
def push_frame(self, bgr_numpy)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L205)

Push a BGR numpy frame to the stream (thread-safe).

Only available when no custom track was provided.

## WebRTCStream.endpoint

```python
def endpoint(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L218)

Full URL for this stream's offer endpoint.

## WebRTCStream.url

```python
def url(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L226)

Path-only URL for this stream's offer endpoint.

## WebRTCStream.handle_offer

```python
async def handle_offer(self, request)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L230)

Handle an SDP offer and return an SDP answer.

## WebRTCStream.set_loop

```python
def set_loop(self, loop)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L281)

## WebRTCStream.cleanup

```python
async def cleanup(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L284)

Close all peer connections for this stream.

## WebRTCStreamManager

```python
class WebRTCStreamManager
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L295)

Manages multiple WebRTC streams and dispatches offer requests.

## WebRTCStreamManager.__init__

```python
def __init__(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L298)

## WebRTCStreamManager.create_stream

```python
def create_stream(self, stream_id, vuer, **kwargs)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L301)

Create and register a new WebRTC stream.

## WebRTCStreamManager.offer_handler

```python
async def offer_handler(self, request)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L309)

Route handler for /webrtc/offer/&#123;stream_id&#125;.

## WebRTCStreamManager.set_loop

```python
def set_loop(self, loop)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L321)

Propagate event loop reference to all streams.

## WebRTCStreamManager.streams

```python
def streams(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L327)

## WebRTCStreamManager.cleanup_all

```python
async def cleanup_all(self)
```

[Source](https://github.com/vuer-ai/vuer-docs/blob/main/src/vuer/webrtc/__init__.py#L330)

Cleanup all streams.
