您的位置:首页 > 其它

ngnix开发(五)将rtmp直播流转换成hls直播流

2016-03-01 19:38 281 查看
1:修改/usr/local/nginx/conf/ngnix.conf,红色字体为添加内容。

#rtmp直播配置

server {

listen 1936;

chunk_size 4000;

application live {

live on;

hls on;

hls_path /usr/local/nginx/html/multimedia/hls/live;

hls_fragment 2s;

hls_playlist_length 6s;

}

}

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root html;

index index.html index.htm;

}

#creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/hls/my-stream-key/index.m3u8"

location /livehls {

types {

application/vnd.apple.mpegurl m3u8;

video/mp2t ts;

}

alias /usr/local/nginx/html/multimedia/hls/live;

add_header Cache-Control no-cache;

}

.......

}

2: 通过ffmpeg 发送 live流

ffmpeg -re -i test.mp4 -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://yourseverIp:1936/live/show

注意:推送的视频格式最好h264,某些格式不支持的话,导致ts文件无法生成。

3:播放链接:http://yourseverIp:1936/live/show.m3u8

1:)live为application的名字,此处由conf定义。

2:)show为直播流的名字,此处由ffmpeg定义。

我在vlc中直接播放此链接。完成!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: