HLS Live Streaming Architecture

A complete HLS live system: Encoder (OBS/FFmpeg) → Media Server (Nginx-rtmp/SRS) → Segmenter → CDN → Player (HLS.js).

Streaming with OBS

OBS Studio is the most popular free streaming software. Configure your RTMP server address and stream key in "Settings → Stream". Recommended: H.264, 2500-6000 kbps, 2-second keyframe interval.

Nginx-rtmp Configuration

rtmp {
  server {
    listen 1935;
    application live {
      live on;
      hls on;
      hls_path /tmp/hls;
      hls_fragment 2s;
      hls_playlist_length 10s;
    }
  }
}
http {
  server {
    listen 8080;
    location /hls {
      types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; }
      root /tmp;
      add_header Cache-Control no-cache;
      add_header Access-Control-Allow-Origin *;
    }
  }
}
Latency tip: Setting hls_fragment to 2 seconds significantly reduces end-to-end latency, typically achieving 6-10 second delay.

CDN Distribution

In production, serve M3U8 files and TS segments through a CDN. Configure cache invalidation for .m3u8 files so players always receive the latest playlist.