Skip to content
Console

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.

{
"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"}
}]
}
FieldTypeDefaultDescription
urlstringrequiredAbsolute ws:// or wss:// URL.
headersobject{}Additional HTTP headers sent during the opening handshake.
subprotocolsstring[][]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.

AVFlow adds these headers to each track connection:

HeaderDescription
X-AVFlow-Audio-Formatpcm_s16le, aac, or opus.
X-AVFlow-Audio-Codec-ConfigBase64 codec initialization bytes for encoded input, when available.
X-AVFlow-Audio-Sample-RateSample rate in Hz.
X-AVFlow-Audio-ChannelsInterleaved channel count.
X-AVFlow-IdentityParticipant identity, when available.
X-AVFlow-Source-NameAVFlow source name, when available.
X-AVFlow-Track-SidTrack SID or stable runtime track ID.
X-AVFlow-Track-NameProvider track name, when available.
X-AVFlow-Track-SourceTrack 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.

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.