前言在Ubuntu中使用Nginx+Nginx-rtmp-module搭建一个简单的rtmp推送直播服务器。服务器环境Ubuntu16.04相关概念RTMP:RTMP协议是RealTimeMessageProtocol(实时消息协议)的缩写,是Adobe公司提出的一种应用层协议。靠flash播放器拉流。请求样式:rtmp://xxx.xxx.xxx.xxx:1935/ttest(namespace)/test(streamingcode)HLS:Apple开发的一套HttpLiveStreaming协议。它的工作原理很简单,就是把一个视频流分成基于HTTP的小文件进行下载。通过读取.m3u8文件,逐个读取视频流片段。请求样式:http://xxx.xxx.xxx.xxx/video(nginx配置路由)/test.m3u8nginx-rtmp-module:基于Nginx的推流服务器测试工具1.推流工具:EasyPushStreaming(ios)2.推流工具:VLCmediaplayer(pc)实施步骤1.安装或升级Nginx模块sudoapt-getinstalllibnginx-mod-rtmp3.编写nginx配置1./etc/nginx/nginx.confuserubuntu;rtmp{server{listen1935;chunk_size4000;applicationtest{liveon;recordoff;hlson;hls_path/usr/local/src/nginx/html/test;hls_fragment1s;hls_playlist_length3s;}}}2./etc/nginx/sites-enables/defaultlocation/video/{alias/usr/local/src/nginx/html/godeyeTest/;#剩下三行配置是为了解决跨域问题add_headerAccess-Control-Allow-Origin*;add_headerAccess-Control-Allow-Methods'GET,POST,OPTIONS';add_headerAccess-Control-Allow-Headers'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';}4.新建路径并重启nginx服务1.mkdir配置中的路径(/usr/本地/src/nginx/html/测试)2。服务nginx重启
