http://nginx-rtmp.blogspot.com/2013/07/hls-variant-playlist.html
HLS variant playlist
In v1.0.2 of nginx-rtmp-module I've added support for HLS variant playlists. Now it's easy to create multi-bitrate HLS streams. The new directive is hls_variant.
hls_variant SUFFIX *;
where SUFFIX is used to match incoming stream name, PARAMs are values added to each variant playlist entry describing the entry. Examples are BANDWIDTH=xxxx or CODECS=yyyy.
http {
listen 80;
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias /tmp;
}
}
rtmp {
server {
listen 1935;
application src {
live on;
exec ffmpeg -i rtmp://localhost/src/$name
-c:a libfdk_aac -b:a 32k -c:v libx264 -b:v 128K -f flv rtmp://localhost/hls/$name_low
-c:a libfdk_aac -b:a 64k -c:v libx264 -b:v 256k -f flv rtmp://localhost/hls/$name_mid
-c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 512K -f flv rtmp://localhost/hls/$name_hi;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
hls_nested on;
hls_variant _low BANDWIDTH=160000;
hls_variant _mid BANDWIDTH=320000;
hls_variant _hi BANDWIDTH=640000;
}
}
}
If you stream incoming video with the following command
ffmpeg -i /var/videos/sintel.mp4 -c:a copy -c:v copy -f flv rtmp://localhost/src/sintel;
then the multi-bitrate HLS stream will be available at the following URL
ffplay http://localhost/hls/sintel.m3u8
This playlist references 3 playlist with low, medium and high qualities.