原理:
宏观流程图
理论姿势
RTMP
RTMP是Real Time Messaging Protocol(实时消息传输协议)
RTMP是一种设计用来进行实时数据通信的网络协议,主要用来在Flash/AIR平台和支持RTMP协议的流媒体/交互服务器之间进行音视频和数据通信。支持该协议的软件包括Adobe Media Server/Ultrant Media Server/red5等。nginx
毛子开发的服务器,很强,很轻nginx-rtmp-module
一梭子操作
1.在服务器上安装nginx
http://blog.csdn.net/catshitone/article/details/48027461
http://feinibuke.blog.51cto.com/1724260/367376
一些指令:
cd /usr/local/nginx/sbin
sudo ./nginx -c /usr/local/nginx/conf/nginx.conf
sudo ./nginx -s stop
2.给nginx安装nginx-rtmp-module
获取
git clone git://github.com/arut/nginx-rtmp-module.git
重新编译安装Nginx
cd ~/nginx-path/
./configure --add-module=/path/to/nginx-rtmp-module
make
sudo make install
修改配置文件
cd /usr/local/nginx/
sudo vim ./conf/nginx.conf
增加
rtmp{
server{
listen 1935;
application mytv{
live on;
}
}
}
运行
sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf
3.主播安装推流软件
OBS
ffmpeg….
4.给用户一个网站.网站里面可以获取直播的资源
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="http://vjs.zencdn.net/5.5.3/video-js.css" rel="stylesheet">
<!-- If you'd like to support IE8 -->
<script src="http://vjs.zencdn.net/ie8/1.1.1/videojs-ie8.min.js"></script>
</head>
<body>
<h1>直播间</h1>
<video id="my-video" class="video-js" controls preload="auto" width="640" height="264"
data-setup="{}">
<source src="rtmp://xxxxxx:1935/mytv/" type="rtmp/flv">
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
<script src="http://vjs.zencdn.net/5.5.3/video.js"></script>
</body>
</html>
在这里,就完成了一个简单直播服务器的搭建,最简单的那种…