Nginx RTMP 功能研究
Nginx-RTMP功能调研
1. RTMP协议介绍...2
2.RTMP server.3
2.1当前的流媒体server.3
2.2Wowza功能...3
3.Nginx-based RTMP server.5
3.1 Nginx rtmp 功能点...5
3.2编译nginx rtmp模块...6
3.3配置以及功能介绍...6
3.4用nginx-rtmp-module搭建直播环境...8
3.5Nginx rtmp对于HLS支持...13
1. RTMP协议介绍
RTMP(Real Time Messaging Protocol)实时消息传送协议是Adobe Systems公司为Flash播放器和服务器之间音频、视频和数据传输开发的私有协议。
RTMP协议就像一个用来装数据包的容器,这些数据可以是AMF格式的数据,也可以是FLV中的视/音频数据。一个单一的连接可以通过不同的通道传输多路网络流。这些通道中的包都是按照固定大小的包传输的。
更多协议的细节可以参见《rtmp specification 1.0》
2. RTMP server
2.1当前的流媒体server
现在主要有两种rtmp server,商业的和开源的。商业的比开源的支持的功能多,个人根据需要选择吧
3. aXeVideo haXe 一个实验性的,轻量级的服务器 http://code.google.com/p/haxevideo/
4. FluorineFx .Net To be defined http://www/fluorinefx.com
5. nginx-rtmp c nginx模块 支持rtmp和HLS https://github.com/arut/nginx-rtmp-module
2.2 Wowza功能
通过对Wowza Media Server的深度定制开发,尚为网络视听管理系统实现了对网络音视频内容的采集、编码、编辑、转码、审核、播出与监控等完整的生命周期管理,突出了以下能力:
对网络视频的录制,采用服务器端录制模式,满足从28Kbps到10Mbps码流范围的H.264编码流的自动化定时收录。
云计算架构设计,服务器端处理。所有编辑任务都处在云端,对编辑机无要求,任务处理快捷简单。
采用云转码技术开发的音视频文件转码、实时流转码,实现了不同格式、码率、分辨率、帧数等参数的自由转换,满足不同终端的播放需求。
结合Wowza Media Server支持多协议多终端的特性,尚为网络视听系统一个平台即可支持多终端设备的视频访问,无论用任何设备都可访问所需的视频内容。
在对多终端内容统一管理的基础之上,还可实现了多终端视频的断点续播功能。用户的播放在一个终端上播放暂停后,用户的信息、节目信息以及断点信息立刻传送给其它终端,实现了不同终端间的断点续播。
扩展性好,可随需增减流媒体服务器来变更系统承载的并发用户数。
除此之外,个人认为完善的DRM版权管理对于视频直播分发是非常重要的功能,服务器状态实时监控是对运营的高效稳定也有非常最要的功能。
3. Nginx-basedRTMP server
3.1 Nginx rtmp 功能点
2. 支持flv/mp4视频格式,输入可以是文件或者HTTP流
6. 支持在线转码 Onlinetranscoding with FFmpeg
7. 支持HLS (HTTP LiveStreaming)需要 libavformat (>= 8. 53.31.100) from ffmpeg (ffmpeg.org)
8. HTTPcallbacks (publish/play/record/update etc)
10. HTTPcontrol module for recording audio/video and dropping clients
11. 先进内存控制技术,可以在使用少量内存的情况下完成流畅的直播功能。
13. Statistics in XML/XSL in machine- & human- readable form
https://github.com/arut/nginx-rtmp-module
https://github.com/arut/nginx-rtmp-module/wiki/Directives
总的来说Nginx-RTMP是个比较轻量的项目,可以满足直播的采集,编码和分发工作,该项目丰富的完善了nginx对视频的支持,特别的nginx-rtmp实现了对HLS的支持。
3.2 编译nginx rtmp模块
./configure--add-module=/path/to/nginx-rtmp-module
./configure--add-module=/path/to/nginx-rtmp-module--add-module=/path/to/nginx-rtmp-module/hls
3.3 配置以及功能介绍
RTMP 直播的一般格式是rtmp://youdomain.com/app/name,其中app的名字对于application的名字,
application live {
live on;
}
2. 配置支持访问控制,你可以指定允许发布的IP以及允许收看的IP:
application live {
live on;
allow publish 127.0.0.1;
deny publish all;
allow play all;
3. 支持Multi-worker streaming工作方式,需要指令rtmp_auto_push on支持,这样nginx有多个worker的情况下,可以将流分发到多个进程进行处理,充分利用服务器资源。
rtmp_auto_push on;
rtmp {
server {
listen 1935;
chunk_size 4000;
# TV mode: one publisher, many subscribers
application mytv {
live on;
}
}
}
4. 流转码的功能,下面的例子使用了exec这种使用外部程序ffmpeg的功能. Ffmpeg是一个强大的媒体处理工具,几乎可以做任意有关video/audio的处理。更多ffmpeg与RTMP流媒体连接用法可以参考以下链接。
http://www.chinavideo.org/viewthread.php?tid=15423
# Transcoding (ffmpeg needed)
application big {
live on;
# Multiple exec lines can be specified.
exec /usr/bin/ffmpeg -re -i rtmp://localhost:1935/$app/$name -vcodec flv -acodec copy -s 32x32 -f flv rtmp://localhost:1935/small/${name};
}
application small {
live on;
# Video with reduced resolution comes here from ffmpeg
}
5.Push和pull模式,用在多个server协助的情况下,输出流可以push,输入流可以pull。
application mypush {
live on;
# Every stream published here
# is automatically pushed to
# these two machines
push rtmp1.example.com;
push rtmp2.example.com:1934;
}
application mypull {
live on;
# Pull all streams from remote machine
# and play locally
pull rtmp://rtmp3.example.com pageUrl=www.example.com/index.html;
}
3.4 用nginx-rtmp-module搭建直播环境
2. 配置nginx-rtmp,完成相关功能配置,可以参考以上描述。
3. 搭建客户端测试环境,本文测试播放器使用的是jwplayer
https://github.com/arut/nginx-rtmp-module项目里面test目录下有相关的播放器设置和配置文件。
- worker_processes 1;
- error_log logs/error.log debug;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid;
- events {
- worker_connections 1024;
- }
- rtmp {
- server {
- listen 1935;
- chunk_size 128;
- publish_time_fix off;
- application myapp {
- live on;
- record keyframes;
- record_path /tmp;
- record_max_size 128K;
- record_interval 30s;
- record_suffix .flv;
- on_publish http://localhost:8080/publish;
- on_play http://localhost:8080/play;
- on_record_done http://localhost:8080/record_done;
- }
- application myapp2 {
- live on;
- }
- # application mypull {
- # live on;
- # pull myapp mystream localhost;
- # }
- # application mypush {
- # live on;
- # push myapp mystream localhost;
- # push myapp2 mystream localhost;
- # }
- }
- }
- http {
- server {
- listen 8080;
- location /publish {
- return 201;
- }
- location /play {
- return 202;
- }
- location /record_done {
- return 203;
- }
- location /stat {
- rtmp_stat all;
- rtmp_stat_stylesheet stat.xsl;
- }
- location /stat.xsl {
- root /home/rarutyunyan/nginx-rtmp-module/;
- }
- location /rtmp-publisher {
- root /home/rarutyunyan/nginx-rtmp-module/test;
- }
- location / {
- root /home/rarutyunyan/nginx-rtmp-module/test/www;
- }
- }
- }
测试用例:
/home/rarutyunyan/nginx-rtmp-module/test/rtmp-publisher
/home/rarutyunyan/nginx-rtmp-module/test/www
测试URL:
http://192.168.100.135:8080/index.html
http://192.168.100.135:8080/rtmp-publisher/player.html
效果:
支持的配置指令有很多,没有一一研究。参见:
https://github.com/arut/nginx-rtmp-module/wiki/Directives
max_streams
syntax: max_streams value
context: rtmp, server
Setsmaximum number of RTMP streams. Data streams are multiplexed into a single datastream. Different channels are used for sending commands, audio, video etc.Default value is 32 which is usually ok for many cases.
exec
Syntax: exec command arg*
Context: rtmp, server, application
Specifiesexternal command with arguments to be executed on every stream published. Whenpublishing stops the process is terminated. Full path to binary should bespecified as the first argument. There are no assumptions about what thisprocess should do. However this feature is useful with ffmpeg for streamtranscoding. FFmpeg is supposed to connect to nginx-rtmp as a client and outputtranscoded stream back to nginx-rtmp as publisher. Substitutions of form$var/${var} can be used within command line:
· $name - stream name
· $app - application name
· $addr - client address
· $flashver - client flashversion
· $swfurl - client swf url
· $tcurl - client tc url
· $pageurl - client page url
Thefollowing ffmpeg call transcodes incoming stream to HLS-ready stream(H264/AAC). FFmpeg should be compiled with libx264 & libfaac support forthis example to work.
3.5 Nginx rtmp对于HLS支持
HLS只请求基本的HTTP报文,与实时传输协议(RTP)不同,HLS可以穿过任何允许HTTP数据通过的防火墙或者代理服务器。它也很容易使用内容分发网络来传输媒体流。
此协议详细内容请参考apple官方网站:https://developer.apple.com/resources/http-streaming/
2. 利用adobe 的fms,4.5版本支持hls,可以参考,
· Streaming audio or video toiPhone, iPod touch, iPad, or Apple TV
· Streaming live events withoutspecial server software
· Sending video on demand withencryption and authentication
下载编译只需要编译m3u8-segmenter.c即可,需要libc2.5以上支持。l
流化可以支持以下两种。第一种尚未找到具体方法,下面的实例是采用第二种基于文件的。
1. 使用ffmpeg + segmenter:首先转化成ts文件,然后分割
参考链接:http://1.richitec.sinaapp.com/?p=64
- application hls {
- hls on;
- hls_path /tmp/app;
- hls_fragment 10s;
- }
- location /hls {
- # Serve HLS fragments
- alias /tmp/app;
- }
使用vlc测试。
测试成功。
Nginx RTMP 功能研究相关推荐
- [转]Nginx RTMP 功能研究(Nginx流媒体)
转自:http://blog.csdn.net/cccallen/article/details/8440191 看点: 1. Nginx 配置信息与使用. (支持 rtmp与HLS配置) 2 ...
- nginx+rtmp实现直播服务端
目前直播系统从功能上分为两种,直播和互动.普通直播对播放延迟要求不高,推流端也能设置本地延迟推流时间.互动直播对低延时要求较高,主要应用在即时通讯和在线教育等行业,从推流端采集到拉流端播放一般延时不超 ...
- nginx rtmp 编码_基于Nginx的媒体服务器技术
国内应用比较多的开源流媒体服务器nginx-rtmp-module一直存在功能少.集群化难度大等问题.在LiveVideoStack线上分享中,PingOS 开源项目组开发工程师.UCloud RTC ...
- ffmpeg,rtmpdump和nginx rtmp实现录屏,直播和录制
ffmpeg,rtmpdump和nginx rtmp实现录屏,直播和录制 2014年 四月 19日 周六 | tags: ffmpeg, rtmp, rtmpdump, nginx, -- (perm ...
- 服务器搭建和使用 ubuntu_Ubuntu中使用Nginx+rtmp搭建流媒体直播服务
一.背景 本篇文章是继上一篇文章<Ubuntu中使用Nginx+rtmp模块搭建流媒体视频点播服务>文章而写,在上一篇文章中我们搭建了一个点播服务器,在此基础上我们再搭建一个直播服务器, ...
- nginx RTMP FFmpeg 视频直播
/***************************************************************************** nginx RTMP FFmpeg 视频直 ...
- ffmpeg推流+NGINX(RTMP)+VLC-QT拉流(Win7)
1 简介 本文旨在在Windows 7系统上实现利用FFmpeg软件推流到部署的带RTMP模块的Nginx流媒体服务器上,在拉流端,基于VLC库的VLC-QT库实现拉流播放. 2 ffmpeg下载安装 ...
- linux 搭建nginx + rtmp服务器
linux 搭建nginx + rtmp服务器 一 环境准备 虚拟机ubuntu 装备,安装一些nginx 必要的依赖和服务 sudo apt-get install libpcre3 libpcr ...
- nginx rtmp视频直播
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接: https://blog.csdn.net/weixin_44707597/art ...
最新文章
- 在linux下创立bash文件,Linux文件管理及bash特性
- Android Studio获得sha1码
- c++反射机制(vcl实现),mfc可依样实现
- python选择排序从大到小_经典排序算法和Python详解之(一)选择排序和二元选择排序...
- 微软公布 Windows Phone 8 多项新特性
- Axios中无法运行 json-server【已解决】
- Top的VIRT是什么
- 高效 Windows 工作环境 Java 开发环境搭建
- 用C语言解决文件合并问题
- 科学巨星的美丽轨迹——走近博弈论大师纳什
- 光影魔术手出现load XAR失败,解决办法。
- Web Editor插件 网页在线编辑器
- http请求返回302处理方案
- Django实训:图书信息管理系统
- openvz相关资料
- android卡刷包自制rom之添加删除,添加/删除ROM内置APP的教程
- 数据库服务器审计系统部署方式,数据库审计系统D2020,agent方式审计如何配置...
- EXCEL中如何删除某一行及以下的所有单元格
- PNAS:浅前馈神经网络识别fMRI功能连接指纹图谱
- 云效上线“云中谁寄锦书来”云端专属密码情书
热门文章
- appium for mac 安装与测试ios说明
- Centos7.1 命令行与图形化界面登陆
- 图解iPhone开发新手教程
- ReentrantReadWriteLock可重入读写锁分析
- 最牛B 的 Linux Shell 命令(一)
- sp_updatestats和update statistics的区别
- CodeForces - 1335F Robots on a Grid(拓扑找环+反向dfs/倍增)
- POJ - 2226 Muddy Fields(最小点覆盖-二分图最大匹配)
- HDU - 1542 Atlantis(线段树+扫描线)
- python操作json_如何使用Python处理JSON数据