websocket
Send audio to a WebSocket server as binary messages. The sink accepts either
raw audio (raw_audio) or an audio_encoder output
(encoded_audio). It does not accept video, captions, or JSON.
For raw input, each message is interleaved signed 16-bit little-endian PCM
(pcm_s16le). For encoded input, each message is one AAC or Opus access unit.
The sink opens one WebSocket connection per input stream.
Example
Section titled “Example”{ "name": "audio_ws", "type": "websocket", "inputs": ["pcm16k"], "config": { "url": "wss://example.com/audio", "headers": { "Authorization": "Bearer <token>" }, "subprotocols": ["audio"] }}Use audio_resample before this sink when the server
requires a specific sample rate or channel count.
To send encoded Opus instead:
{ "nodes": [{ "name": "opus", "type": "audio_encoder", "inputs": ["audio_mix"], "config": {"codec": "opus", "bitrateBps": 64000} }], "sinks": [{ "name": "audio_ws", "type": "websocket", "inputs": ["opus"], "config": {"url": "wss://example.com/audio"} }]}Config
Section titled “Config”| Field | Type | Default | Description |
|---|---|---|---|
url | string | required | Absolute ws:// or wss:// URL. |
headers | object | {} | Additional HTTP headers sent during the opening handshake. |
subprotocols | string[] | [] | Ordered WebSocket subprotocols offered to the server. |
The managed connection layer owns the outbound connection and reconnect policy. URL, headers, and subprotocols are not exposed to media processing components.
Handshake metadata
Section titled “Handshake metadata”AVFlow adds these headers to each track connection:
| Header | Description |
|---|---|
X-AVFlow-Audio-Format | pcm_s16le, aac, or opus. |
X-AVFlow-Audio-Codec-Config | Base64 codec initialization bytes for encoded input, when available. |
X-AVFlow-Audio-Sample-Rate | Sample rate in Hz. |
X-AVFlow-Audio-Channels | Interleaved channel count. |
X-AVFlow-Identity | Participant identity, when available. |
X-AVFlow-Source-Name | AVFlow source name, when available. |
X-AVFlow-Track-Sid | Track SID or stable runtime track ID. |
X-AVFlow-Track-Name | Provider track name, when available. |
X-AVFlow-Track-Source | Track source such as microphone, when available. |
Each WebSocket binary message contains only one PCM chunk or encoded access unit. AVFlow reconnects failed connections according to the job reconnect policy. During sustained backpressure it drops the oldest queued audio to preserve real-time delivery.
Pricing
Section titled “Pricing”Raw PCM has no audio encoding-duration fee. An audio_encoder input incurs the
normal audio encoding-duration fee. In both modes, successfully written payload
bytes are billed at $0.12/GB.
Sink pricing.