您好,欢迎访问一九零五行业门户网

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

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中直接播放此链接。完成!!!
以上就介绍了ngnix开发(五)将rtmp直播流转换成hls直播流,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息