1.配置nginx
配置rtmp直播
rtmp {
server {
listen 1935;
application myapp {
live on;
#record keyframes;
#record_path /tmp;
#record_max_size 128K;
#record_interval 30s;
#record_suffix .this.is.flv;
#on_publish http://localhost:8080/publish;
#on_play http://localhost:8080/play;
#on_record_done http://localhost:8080/record_done;
}
application live {
live on; #开启实时
hls on; #开启hls
hls_path /usr/local/etc/nginx/html/multimedia/hls; #hls的ts切片存放路径
hls_fragment 2s; #本地切片长度
hls_playlist_length 6s; #HLS播放列表长度
}
}
配置hls拉流
这个配置为了客户端
能够以http协议获取HLS的拉流
location /live {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias /usr/local/etc/nginx/html/multimedia/hls/;
add_header Cache-Control no-cache;
重启nginx
sudo nginx -s reload
推流
rtmp://127.0.0.1:1935/live/room8