Skip to content

HLS (HTTP Live Streaming)

RUSEON Core provides a standard low-latency HLS feed packaged in MPEG-TS containers with zero-transcoding.


Live Segments & Sliding Window

  • Target Duration: 2.0 seconds. Segments are cut strictly on I-frames immediately upon reaching the target duration.
  • Sliding Window: The live manifest contains a sliding window of 5 segments (~10 seconds).
  • Buffer Pool Recycling: Video segments are generated in memory using a sync.Pool of pre-allocated 1 MB buffers (bufferPool), reducing garbage collection churn under high load.
  • Offline Discontinuity: If a camera disconnects, the HLS muxer generates #EXT-X-DISCONTINUITY tags to prevent player crashes upon reconnection.

Lazy HLS Watchdog

To conserve CPU and memory when nobody is watching, HLS muxing can be dynamically activated on demand:

  • Enabled per-camera via lazy_hls: true.
  • When the first player requests a playlist, the muxer immediately starts and pulls a 4-second pre-buffer directly from the in-memory RingBuffer, providing instant video playback.
  • If no HTTP requests for the stream are received for 60 seconds, the background muxer automatically shuts down.

WebVTT AI Metadata Synchronization

RUSEON Core generates a master HLS playlist that includes a parallel WebVTT subtitle track:

m3u8
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="AI Metadata",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI="subs.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=1920x1080,SUBTITLES="subs"
stream.m3u8

WebVTT subtitle cues contain serialized JSON metadata (bounding boxes, class names, confidence scores). Subtitle cues are strictly synchronized with video timestamps using the MPEG-TS header:

vtt
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

00:00:00.000 --> 00:00:02.000
{"boxes":[{"x":120,"y":340,"w":150,"h":280,"label":"person","score":0.94}]}

HTTP Endpoints

EndpointDescription
GET /stream/hls/:id/index.m3u8Master playlist referencing video and WebVTT subtitle streams.
GET /stream/hls/:id/stream.m3u8Sliding window video playlist containing .ts segment references.
GET /stream/hls/:id/subs.m3u8Subtitle playlist containing .vtt metadata segment references.
GET /stream/hls/:id/:segmentFetches a raw video segment (.ts) or metadata segment (.vtt).

Released under the MIT License.