Skip to content

WebSocket

im-pingo edited this page Mar 26, 2026 · 1 revision

English | 中文

WebSocket Streaming

LiveForge supports live streaming over WebSocket, delivering FLV, TS, or FMP4 data as binary WebSocket frames. This enables browser-based players using the Media Source Extensions (MSE) API.

URL Format

ws://host:8080/ws/{app}/{key}.{format}

Supported formats: flv, ts, mp4

Examples

ws://localhost:8080/ws/live/stream1.flv
ws://localhost:8080/ws/live/stream1.ts
ws://localhost:8080/ws/live/stream1.mp4

Shared Listener

WebSocket streaming shares the same HTTP listener as HTTP Streaming. No additional configuration or ports are needed -- the /ws/ path prefix routes requests to the WebSocket handler automatically.

How It Works

  1. The client upgrades an HTTP connection to WebSocket
  2. The server sends init data (FLV header or FMP4 init segment) as the first binary message
  3. Subsequent muxed media data is pushed as binary WebSocket frames
  4. The connection closes when the client disconnects or the stream ends

Formats

Format Extension Content Typical Browser Player
FLV .flv FLV tags (video + audio) flv.js, mpegts.js
TS .ts MPEG-TS packets mpegts.js, hls.js
FMP4 .mp4 fMP4 init + moof/mdat fragments Native MSE

Use Cases

  • Browser-based low-latency playback -- WebSocket-FLV with flv.js or mpegts.js provides sub-second latency in browsers
  • Custom web players -- build real-time dashboards or monitoring UIs with MSE
  • Bypassing HTTP chunked-transfer limitations -- some CDNs or proxies buffer chunked HTTP responses; WebSocket avoids this

Clone this wiki locally