rtmp(Real Time Messaging Protocol)实时消息传送协议是Adobe Systems公司为Flash播放器和服务器之间音频、视频和数据传输开发的私有协议。 它有三种变种:
RTMP协议就像一个用来装数据包的容器,这些数据可以是AMF格式的数据,也可以是FLV中的视/音频数据。一个单一的连接可以通过不同的通道传输多路网络流。这些通道中的包都是按照固定大小的包传输的。
RTMP交互图
现在主要有两种rtmp server,商业的和开源的。商业的比开源的支持的功能多 商业的有FMS Wowza FMS是Adobe公司的产品,license非常昂贵。下面就wowza这个商业软件讲下流媒体Server,不仅仅是RTMP Server,在达到生产环境所需要的功能。wowza最突出的特定是多终端适应性,这个在如今多媒体融合的网络环境下有很强的实用意义。究其原理并无深 入研究。国内尚为视讯是其代理公司。 Wowza Media Server是一款高性能、多线程的流媒体服务器软件。专为多种终端设备提供音视频内容播放服务,支持iOS、windows、Android、 BlackMerry等系统的终端设备,以HTTP、RTSP/ RTP、RTMP传输协议的流播放,还支持利用机顶盒进行播放的IPTV。 开源RTMP server
Nginx rtmp功能点
项目地址:https://github.com/arut/nginx-rtmp-module nginx-rtmp-module Directives:https://github.com/arut/nginx-rtmp-module/wiki/Directives 总的来说Nginx-rtmp是个比较轻量的项目,可以满足直播的采集,编码和分发工作,该项目丰富的完善了nginx对视频的支持,特别的nginx-rtmp实现了对HLS的支持。 Nginx下rtmp模块安装 基于《lnmp一键安装包》环境下 cd lnmp/src yum -y install git wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz tar xzf yasm-1.2.0.tar.gz cd yasm-1.2.0 ./configure make && make install cd .. git clone git://git.videolan.org/x264.git cd x264 ./configure --enable-shared make && make install cd .. wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz tar xzf lame-3.99.5.tar.gz cd lame-3.99.5 ./configure --enable-nasm make && make install cd .. wget http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz tar xzf libogg-1.3.1.tar.gz cd libogg-1.3.1 ./configure make && make install cd .. wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz tar xzf libvorbis-1.3.3.tar.gz cd libvorbis-1.3.3 ldconfig ./configure make && make install cd .. git clone http://git.chromium.org/webm/libvpx.git cd libvpx ./configure --enable-shared make && make install cd .. wget http://downloads.sourceforge.net/faac/faad2-2.7.tar.gz tar xzf faad2-2.7.tar.gz cd faad2-2.7 ./configure make && make install cd .. wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz tar xzf faac-1.28.tar.gz cd faac-1.28 sed -i 's@^char \*strcasestr@//char *strcasestr@' ./common/mp4v2/mpeg4ip.h ./configure make && make install cd .. wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz tar xzf xvidcore-1.3.2.tar.gz cd xvidcore/build/generic ./configure make && make install cd ../../../ git clone git://source.ffmpeg.org/ffmpeg.git cd ffmpeg ./configure --prefix=/usr --enable-version3 --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-shared --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads make && make install ldconfig ffmpeg cd .. wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz git clone git://github.com/arut/nginx-rtmp-module.git tar xzf nginx_mod_h264_streaming-2.2.7.tar.gz sed -i '158,161s@^@//@g' nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c cd nginx-1.4.4 make clean ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-ld-opt=-ljemalloc --with-http_mp4_module --add-module=../nginx_mod_h264_streaming-2.2.7 --add-module=../nginx-rtmp-module make if [ -e "objs/nginx" ];then /bin/mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx$(date +%m%d) /bin/cp objs/nginx /usr/local/nginx/sbin/nginx service nginx restart fi 配置Nginx视频点播 RTMP直播的一般格式是rtmp://www.linuxeye.com/app/name,其中app的名字对于application的名字, rtmp { #保存所有rtmp配置的块 server { #声明一个rtmp实例 listen 1935; #给Nginx添加一个监听端口以接收rtmp连接 chunk_size 4096; #流整合的最大的块大小。默认值为4096。这个值设置的越大CPU负载就越小。这个值不能低于128 application mp4 { #app的名字为mp4 live on; #切换直播模式,即一对多广播 play /home/wwwroot/www.linuxeye.com/mp4; #播放指定mp4文件目录 } } }参考: 《Nginx rtmp模块nginx-rtmp-module指令详解》 《ffmpeg与rtmp流媒体连接用法》 原文地址:http://blog.linuxeye.com/383.html 转载请保留固定链接: https://linuxeye.com/configuration/1981.html |