Windows nginx RTMP ==> 直播&&点播 [android][js]

来源:互联网 发布:海安东华软件招聘 编辑:程序博客网 时间:2024/06/06 04:13

部署环境:windows10
最终结果:HLS点播(随意拖动进度条的那种)、直播(rtmp)、HLS直播(流转换)
知识点:ffmpeg(强大的视音频工具)、nginx windows版本使用、直播点播介绍、obs工具 vlc工具的使用等
协议:RTMP、HLS


参考:ubuntu 下 nginx 直播 点播 博客

http://selimatmaca.com/index.php/live-streaming(英文)

| Part1 - Live Streaming Introduction |

| Part2 - Encoder Software - Adding IP Camera into OBS Studio |

| Part3 - Installing Nginx with RTMP Module and Streaming RTMP | |

| Part4 - Installing FFMPEG with Extra Encoding and Decoding Libraries | |

| Part5 - HLS Streaming with Nginx Rtmp Module | |

| Part6 - VideoJS Player for HLS Streaming | |

| Part7 - HLS Streaming over HTTPS | |


下载文件

为什么是这个版本呢 (nginx 1.7.11.3 Gryphon)(这是http://nginx-win.ecsds.eu/
组织编译好的,非官方)
这个版本好像是windows平台最后一款支持rtmp直播模块的nginx windows编译版本(非官方)

其他版本不行么?
可以啊,自己编译(推荐虚拟机编译)

vm虚拟机下载及密钥
http://blog.csdn.net/qqduxingzhe/article/details/78217192

下载 nginx 1.7.11.3 Gryphon
http://nginx-win.ecsds.eu/download/nginx 1.7.11.3 Gryphon.zip

下载完成后解压;
将解压后的目录名:nginx 1.7.11.3 Gryphon改成:nginx-1.7.11.3-Gryphon

下载服务器状态检查程序 stat.xsl
https://github.com/arut/nginx-rtmp-module/

将nginx-rtmp-module-master.zip解压后复制到目录:nginx-1.7.11.3-Gryphon下,
保证stat.xls的目录为:nginx-1.7.11.3-Gryphon\nginx-rtmp-module\stat.xsl


配置文件

想了解更多关于nginx的知识(尤其是服务器配置,可查看)
《实战Nginx:取代Apache的高性能Web服务器》pdf电子书下载(本书有点老了,)
http://blog.licess.com/nginx-pdf-download/

nginx-1.7.11.3-Gryphon 文件夹下

配置文件 conf\nginx-win.conf插入如下内容

1 rtmp 直播 接收端处理RTMP协议

rtmp { # 配置RTMP模块    server { # 服务器        listen 1935; # 监听端口, 默认为1935        chunk_size 4000; # 数据块大小 4000        application live { # 应用名称, 可理解为直播房间的名称            live on; # 直播 [on]开启        }    }}

2 HLS 直播 接收端处理HLS协议

rtmp {    server {        listen 1935;        chunk_size 4000;        application hls {            live on;            hls on; # hsl开启            hls_path C:/nginx-1.7.11.3-Gryphon/html/hls; # hls路径            hls_fragment 5s; # hls碎片时间        }    }}

启动服务器

进入windows的cmd;

cd nginx-1.7.11.3-Gryphon
nginx.exe -c conf\nginx-win.conf

2.png

http://localhost/,可访问

1.png


直播 播放端 OBS 开源 跨平台 可编程

前提:配置文件
OBS open broadcast software 下载
https://obsproject.com/download

开启OBS,配置媒体源,当前为本地文件 licha.mkv
配置OBS软件,参考:http://selimatmaca.com/index.php/live-streaming/138-encoder-software

2.png

配置OBS,流媒体
rtmp 协议
localhost 自定义流媒体服务器访问地址
live 最上面的配置文件 application live
test 1流名称 hls协议,或者 2流密钥 rtmp协议

3.png

4.png

点击,开启推流


windows演示 ==> 直播 接收端 VLC 开源 跨平台

1 最上面的配置文件,配置RTMP直播
上述,配置好OBS之后,
VLC打开网络串流,访问,rtmp://localhost/live/test

6.png

2 最上面的配置文件,配置HLS直播

7.png


android ==> 直播 接收端 VLC

Android 如何直播RTMP流 HLS流

http://www.truiton.com/2015/03/stream-rtmp-live-android/(英文)
开启chrome翻译的话,看起来难度不大

vlc lib android 文档
https://wiki.videolan.org/LibVLC/#libVLC_on_Android


web 浏览器 ==> 直播 接收端 js

videojs

videojs的话,支持RTMP 需要额外的插件,可能以后都不支持RTMP了
flash可能、马上、很快,要死了?


参考文章

windows下 OBS+nginx 实现rtmp直播流的基础搭建
http://www.jianshu.com/p/0e751c8b8fed

很多,,


end

阅读全文
0 0
原创粉丝点击