标签:
核心:服务端(nginx-rtmp-module) + 推流端(OBS) + 接受端(jwplayer)
地址:https://github.com/arut/nginx-rtmp-module
cd ./nginx-1.10.0/
./configure --add-module=/path/to/nginx-rtmp-module --with-http_ssl_module make make install
注:根据实际情况修改两处代码路径
rtmp { server { listen 1935; application mytv { live on; } } }
注:mytv是应用名称
http { server { listen 8080; # This URL provides RTMP statistics in XML location /stat { rtmp_stat all; # Use this stylesheet to view XML as web page # in browser rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { # XML stylesheet to view RTMP stats. # Copy stat.xsl wherever you want # and put the full directory path here root /data/wwwroot/rtmp/; } } }
把nginx-rtmp-module文件夹中的stat.xsl复制到/data/wwwroot/rtmp/文件夹中
监控地址:http://localhost:8080/stat
地址:https://obsproject.com/download
推流地址:rtmp://192.168.240.128/mytv/ #记得修改IP,下同
其他配置参考:http://www.douyu.com/cms/zhibo/201311/13/250.shtml
此时可以监听到【publishing】状态的进程
注:记得开放1935端口
地址:https://dashboard.jwplayer.com/#/players/downloads #需要注册登录
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="my_video"></div> </body> </html> <script src="./jwplayer/jwplayer.js"></script> <script> jwplayer.key = "yourkey"; jwplayer(‘my_video‘).setup({ file: ‘rtmp://192.168.240.128/mytv/‘, }); </script>
注:记得修改key
地址:https://github.com/arut/nginx-rtmp-module/wiki/Directives#on_publish
rtmp { server { listen 1935; on_publish http://localhost/rtmp/auth.php; application mytv { live on; } } }
注:记得重启nginx
<?php if ($_POST[‘key‘] == ‘root‘) { header(‘HTTP/1.1 200 OK‘); header(‘Status: 200 OK‘); } else { header(‘HTTP/1.1 403 Forbidden‘); header(‘Status: 403 Forbidden‘); }
返回2xx RTMP通过,返回3xx RTMP重定向,其他均为失败。
请根据你的业务逻辑修改验证流程。
流秘钥:?key=root #不是推流地址
标签:
原文地址:http://www.cnblogs.com/xiejixing/p/5620895.html