HLS (HTTP Live Streaming) is a live video broadcasting protocol by Apple. It’s current standartization status is IETF draft. It splits incoming stream coded with MPEG (H.264 и AAC) into little chunks (*.ts files) and forms a playlist (*.m3u8) which is served to users. When a users queries for a stream his client (browser) start a simple file download process chunk by chunk. Visit https://developer.apple.com/streaming/ for more information.
This protocol is supported by Safari for MAC and IOS, stock browser and Chrome for Android. Visit http://www.jwplayer.com/html5/hls/ for more info. On a desktop with Windows or Linux you can use VLC player to open m3u8.
Advantages:
– pure HTML5: <video src=’http://<server name>/playlist.m3u8′ width=’640′ height=’360′ controls=’controls’></video> – and that’s it.
– there is no need for a browser plugins, especially so vunerable as flash
– supports AES and adaptive bitrate.
In our case we need another configuration for Wowza and nginx retranslators.
1) For Wowza create a Live origin app (HTTP) and edit /usr/local/WowzaMediaServer/conf/live/Application.xml
<HTTPStreamer> <Properties> <Property> <Name>httpOriginMode</Name> <Value>on</Value> </Property> <!-- Apple HLS: cache control --> <Property> <Name>cupertinoCacheControlPlaylist</Name> <Value>max-age=1</Value> </Property> <Property> <Name>cupertinoCacheControlMediaChunk</Name> <Value>max-age=3600</Value> </Property> <!-- Smooth Streaming: cache control --> <Property> <Name>smoothCacheControlPlaylist</Name> <Value>max-age=1</Value> </Property> <Property> <Name>smoothCacheControlMediaChunk</Name> <Value>max-age=3600</Value> </Property> <Property> <Name>smoothCacheControlDataChunk</Name> <Value>max-age=3600</Value> </Property> <!-- Flash HDS: cache control --> <Property> <Name>sanjoseCacheControlPlaylist</Name> <Value>max-age=1</Value> </Property> <Property> <Name>sanjoseCacheControlMediaChunk</Name> <Value>max-age=3600</Value> </Property> <Property> <Name>cupertinoOnChunkStartResetCounter</Name> <Value>true</Value> <Type>Boolean</Type> </Property> </Properties> </HTTPStreamer>
2) And convert nginx to a simple proxy server
http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; proxy_cache_path /tmp/hls_cache levels=1:2 keys_zone=pcache:1024m max_size=10048m inactive=10d use_temp_path=off; client_header_timeout 10m; client_body_timeout 10m; send_timeout 10m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 4 2k; request_pool_size 4k; keepalive_timeout 65; server { listen 1936; server_name <server name>:1936; location / { types { application/vnd.apple.mpegurl m3u8; } proxy_cache pcache; proxy_pass http://<wowza ip>:1935; } } }
3) Now you can use your favorite player (flowplayer would work too). And serve users your broadcast.