通过nginx搭建hls流媒体服务器

通过录像文件模拟直播源,通过rtmp协议推送到nginx服务器

 nginx 配置文件 增加

[html] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. rtmp {    
  2.     server {    
  3.         listen 1935;    
  4.        application hls {    
  5.              live on;    
  6.              hls on;    
  7.              hls_path /tmp/app;    
  8.              hls_fragment 5s;    
  9.   
  10.        }    
  11.     }    
  12. }    

http 下面增加

[html] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. location /hls {    
  2.            #server hls fragments    
  3.            types{    
  4.              application/vnd.apple.mpegurl m3u8;    
  5.              video/mp2t ts;    
  6.            }    
  7.         alias /tmp/app;    
  8.         expires -1;    
  9.         }    

在 safari浏览器或者vlc中打开 测试地址:  http://192.168.1.105:8080/hls/test.m3u8

可以直播了

原文地址:https://www.cnblogs.com/lidabo/p/6405255.html