项目:主播-。- 要求主播和玩家有互动,并且主播分布在全国各地 通过发布视频流达到直播

目前应用软件 fms4.5 当做流发布服务器 目前未采用fms集群形式,高可用的源和边缘节点都未建立

待一步步摸索,因目前CDN厂商基本都可进行FMS加速,使用FMS流共享 部署边缘服务器 并使用智能

DNS分配用户请求 所以如果不记成本和使用不广泛的话 个人感觉还是交付给CDN厂商做较好

说下FMS4.5.的建立过程

Flash Media Server 4.5
OSMF Simple Player For Http Dynamic Streaming

下载地址:http://www.osmf.org/downloads/OSFMPlayer_zeri2.zip

Apache2 FMS4.5安装过程中会安装一个Apache2 方便web管理,安装好后可看demo

下面是安装配置过程:
安装FMS4.5,默认安装到/opt/adobe/fms/

tar -zxvf FlashMediaServer4.5_x64.tar.gz

cd FMS_4_5_5_r4013

./installFMS

Do you agree with the license agreement? (y/n): y

Please enter your Adobe Flash Media Server 4.5 serial number. 输入序列号~~~如果没有就默认吧 可以从网上找个 默认的话回到开发版

Default [/opt/adobe/fms]:  默认安装路径

Please enter the administrative username: 管理员用户名,搭建完成后可通过web管理
Please enter the administrative password: 管理员密码
Default user [fms]:  默认启动用户
User "fms" does not exist. Do you want to create it?(y/n) 如无fms用户则创建
Default [y]:  默认Y
Please enter a valid user group for the "fms" user. 创建组
Default group [fms]:

Do you want to install apache? (y/n) fms安装会内嵌安装apache 可选是否安装
Default [y]:
You have chosen to install Apache.
Would you like for Apache or FMS to listen on port 80?
Enter 'y' for Apache, 'n' for FMS. (y/n)
Default [y]:
Please enter the Adobe Flash Media Server port(s), comma-separated
Default [1935,80]: FMS 监听端口 1935 80
Please enter the port to use for the Admin service. You can only specify one
admin port.
Default [1111]:     FMSadmin 管理端口 默认1111
Do you want the Adobe Flash Media Server service to run as a
daemon? (y/n)  后台运行 之后还会让你选择是否安装完后自动启动
Default [y]:    
Proceed with the installation? (y/n/q):  确认信息

下载安装OSMF Simple Player,将下载到的Player解压并放到: /opt/adobe/fms/webroot/OSFMPlayer 目录中
默认情况向, FMS监听80端口接收traffic然后传递给Apache的8134端口(FMS自带的Apache被配成了监听8134端口),这个传递过程在高网络负载下会带来性能的问题,因此,做以下配置来解决这个问题。
修改fms.ini, 将其中的ADAPTOR.HOSTPORT = :1935,80 一行改为ADAPTOR.HOSTPORT = :1935; 不让FMS监听80端口;
同时,将其中 HTTPPROXY.HOST = :8134一行改为:  HTTPPROXY.HOST =
这样便去掉了以上的代理转发过程。
rootinstall/Apache2.2/conf/httpd.conf文件中的 Listen 8134 一行不用更改,这样便让FMS 安装的Apache继续监听8134端口,而我们系统中的Apache仍监听80端口,这样便不会冲突。(当然这样带来的坏处就是后面任何HTTP访问都需要带8134

HTTP Origin Module 不用配置,FMS4.5自带安装的Apache都已经配置好了这些支持Http Dynamic Streaming的模块 主要用于点播 和直播时下发流媒体数据到观看端;

客户端录制测试

Flash Media Live Encoder 3.2
打开其子目录Conf下面的config.xml文件
修改/flashmedialiveencoder_config/mbrconfig/streamsynchronization/enable节点值为true.
   (使用绝对时间)
     <mbrconfig>
        <streamsynchronization>
             <enable>true</enable>

配置FMS server在直播时使用绝对时间,打开rootinstall/applications/livepkgr/Application.xml
    修改/Application/StreamManager/Live/AssumeAbsoluteTime节点为true.
    <Application>
       <StreamManager>
         <Live>
           <AssumeAbsoluteTime>true</AssumeAbsoluteTime>
         </Live>
       </StreamManager>
    </Application>

配置rootinstall/conf/Server.xml,修改
   <Root>
     <Server>
       <ResourceLimits>
          <RecBuffer>
             <MaxFlushTime> 3 <MaxFlushTime>
    将<MaxFlushTime>的值改为1.

验证直播和点播
  cd rootinstall
  ./fmsmgr server fms restart  -- 重新启动FMS
  ./fmsmgr adminserver restart -- 重新启动Admin Server

证VOD 是按Dynmaic Http Streaming   http://yourserverip:8134/
进入可看到默认主页

“Launch Flash Media Administration Console”,可以通过此入口来管理FMS server(用安装时创建的用户名和密码)
“(HDS) HTTP Dynamic Streaming sample” 点击进去,可以看到视频播放界面 可测试视频播放是否分段 即验证HTTP Dynamic Streaming VOD方式是成功的。


启动上面安装的Flash Media Live Encoder 3.2,选preset Custom, 视频选H264,29.9fps,分辨率352x288
码率可选3个100, 200, 350,H264可设置每2秒一个关键帧等,选MP3做音频等。
在右边的Stream to Flash Media Server的FMS URL 里面填上:rtmp://yourserverip/livepkgr
在Stream一栏填上:livestream%i?adbe-live-event=liveevent (如果上面选了MBR3个码率直播),如果选了一个码率直播则填上:livestream?adbe-live-event=liveevent  stream项写频道名
然后点开始即可发布直播
http://yourserverip:8134/OSFMPlayer/OSMFPlayer.html
然后用OSMFPlayer播放以下地址即可看到直播图像:

*.f4m -- Flash Media Manifest file. Contains information about codec, resolution, and the availability of
multi-bitrate files.类似于苹果HLS方案中的m3u8,是mainfest索引文件,里面包括编码,分辨率码率等
*.f4x -- Index file. Contains the location of specific fragments within a stream.
*.f4f -- A segment. The tool outputs one or more F4F files. Each file contains a segment of the sourcefile. Each segment contains one or more fragments of content. A player can use a URL to address eachfragment.


将rootinstall/samples目录下的videoPlayer目录拷贝到rootinstall/webroot/下,这是一个支持RTMP协议播放的Flash播放器,类似于上面的OSMF播放器。
在Flash Media Live Encoder3.2那里的FMS URL那里填上: rtmp://yourserviceip/live
在下面的stream那里填上livestream
观看端用浏览器打开:http://yourserverip:8134/videoPlayer/videoPlayer.html, 然后在页面下部的stream URL那里输入:
rtmp://yourserverip/live/livestream,并勾选中LIVE,然后点击Play Stream即可观看。
这里观看者用的是RTMP下载方式而不是HTTP下载方式。

关于FMS分流

另找一台fms服务器

在main.asc中写入

 
  
  1. //程序启动时执行

  2. application.onAppStart = function() {

  3. this.myNC= new NetConnection();  

  4. this.myNC.onStatus = NC_onStatus;

  5. this.myNC.connect("rtmp://cuplayer.com/tvSet");

  6. };

  7. function NC_onStatus(info){    

  8.     switch (info.code) {

  9.   case "NetConnection.Connect.Success" :

  10. application.myStream = Stream.get("cctv1");

  11. application.myStream.onStatus = NS_onStatus;

  12.    if (application.myStream){

  13.     application.myStream.play("cctv1",-2, -1,false,application.myNC);

  14.    }

  15.      trace("CuPlayer.com提示:连接成功!");    

  16.    break;

  17.   case "NetConnection.Connect.Failed" :

  18.    trace("CuPlayer.com提示:连接失败!");

  19.    break;

  20.   case "NetConnection.Connect.Rejected" :

  21.    trace("CuPlayer.com提示:连接失败!");

  22.    break;

  23. }

  24. }

  25. function NS_onStatus(info){  

  26.   trace(info.code);    

  27. }

注:cctv1为流名称