Skip to content

HTTP Streaming

pingo edited this page Mar 28, 2026 · 3 revisions

English | 中文

HTTP Streaming

The HTTP streaming module serves HLS, DASH, HTTP-FLV, HTTP-TS, and FMP4 over a single HTTP listener. WebSocket streaming also shares this listener.

Configuration

http_stream:
  enabled: true
  listen: ":8080"
  cors: true
  # tls: null
  hls:
    segment_duration: 6
    playlist_size: 5
  dash:
    segment_duration: 6
    playlist_size: 30
  llhls:
    enabled: false
    part_duration: 0.2
    segment_count: 4
    container: fmp4
Field Type Default Description
enabled bool true Enable/disable the HTTP streaming module
listen string ":8080" HTTP listen address
cors bool true Enable CORS headers (Access-Control-Allow-Origin: *)
tls *bool (null) Per-module TLS override
hls.segment_duration float 6 Target HLS segment duration in seconds
hls.playlist_size int 5 Maximum number of segments in the HLS playlist
dash.segment_duration float 6 Target DASH segment duration in seconds
dash.playlist_size int 30 Maximum number of segments in the DASH manifest

URL Format

All HTTP streaming URLs follow the pattern http://host:port/{app}/{key}.{format}.

Format URL Pattern Content-Type
HLS playlist /{app}/{key}.m3u8 application/vnd.apple.mpegurl
HLS segment /{app}/{key}/{N}.ts video/mp2t
LL-HLS playlist /{app}/{key}.m3u8 application/vnd.apple.mpegurl
LL-HLS partial segment /{app}/{key}/{MSN}.{part}.m4s video/mp4
LL-HLS init segment /{app}/{key}/init.mp4 video/mp4
DASH manifest /{app}/{key}.mpd application/dash+xml
DASH video init /{app}/{key}/init.mp4 video/mp4
DASH audio init /{app}/{key}/audio_init.mp4 video/mp4
DASH video segment /{app}/{key}/v{N}.m4s video/mp4
DASH audio segment /{app}/{key}/a{N}.m4s video/mp4
HTTP-FLV /{app}/{key}.flv video/x-flv
HTTP-TS /{app}/{key}.ts video/mp2t
HTTP-FMP4 /{app}/{key}.mp4 video/mp4

Examples

http://localhost:8080/live/stream1.m3u8
http://localhost:8080/live/stream1.mpd
http://localhost:8080/live/stream1.flv
http://localhost:8080/live/stream1.ts
http://localhost:8080/live/stream1.mp4

HLS

HLS (HTTP Live Streaming) segments the live stream into .ts (MPEG-TS) files and generates an .m3u8 playlist.

  • Segments are created on each keyframe boundary, targeting segment_duration seconds
  • The playlist is a sliding window containing the most recent playlist_size segments
  • The server waits for at least one segment before serving the playlist

Play with FFplay:

ffplay http://localhost:8080/live/stream1.m3u8

LL-HLS (Low-Latency HLS)

Field Type Default Description
llhls.enabled bool false Enable LL-HLS mode (replaces regular HLS for .m3u8 requests)
llhls.part_duration float 0.2 Target partial segment duration in seconds (PART-TARGET)
llhls.segment_count int 4 Number of completed segments in the sliding window
llhls.container string fmp4 Container format: fmp4 (recommended) or ts/mpegts

When enabled, .m3u8 requests serve an LL-HLS playlist (HLS version 9) with partial segments, blocking playlist reload, delta updates, and preload hints. Regular HLS and LL-HLS are mutually exclusive per server instance — set llhls.enabled: true to use LL-HLS, or false to use regular HLS.

Container aliases: mpegts and mpeg-ts are automatically normalized to ts.

LL-HLS features:

  • EXT-X-PART — partial segments (~200ms) for sub-second latency
  • CAN-BLOCK-RELOAD — server holds response until new content is available
  • EXT-X-PRELOAD-HINT — client preloads next partial before it exists
  • EXT-X-SKIP — delta playlist updates reduce bandwidth
  • Target latency: ~2 seconds with default settings

Supported players: Safari (native), hls.js 1.0+ (with lowLatencyMode: true)

# Enable LL-HLS in config, then:
ffplay http://localhost:8080/live/stream1.m3u8

DASH

DASH (Dynamic Adaptive Streaming over HTTP) uses fMP4 segments with an MPD manifest.

  • Uses SegmentTimeline with explicit per-segment timing for accurate playback
  • Video and audio are served as separate AdaptationSets with independent init and media segments
  • The server waits for at least 3 segments before serving the MPD to ensure stable segment duration calculation
  • DASH segments use 1-based numbering in the MPD, mapped to 0-based internal sequence numbers

Play with FFplay:

ffplay http://localhost:8080/live/stream1.mpd

HTTP-FLV / HTTP-TS / HTTP-FMP4

These formats deliver a continuous chunked-transfer stream over HTTP. The connection stays open and the server pushes muxed data as it becomes available.

Format Description
HTTP-FLV FLV container with FLV header, then tag-by-tag streaming
HTTP-TS MPEG-TS packets streamed continuously
HTTP-FMP4 Fragmented MP4 with init segment followed by moof+mdat fragments

Play with FFplay:

ffplay http://localhost:8080/live/stream1.flv
ffplay http://localhost:8080/live/stream1.ts
ffplay http://localhost:8080/live/stream1.mp4

All chunked formats benefit from GOP cache -- new subscribers receive the latest keyframe group immediately for instant startup.

Clone this wiki locally