背景:因工做须要,要研究一些流媒体服务器相关的技术,主要是为了搭建直播所用的服务器,本文是基于CentOS7搭建FMS流媒体服务器,利用OBS推流工具可实现简单的直播、观看功能。先说明一下AMS全称是adobe media server,在5.0版本以前名称是FMS(flash media server)。html
下载nginx
咱们能够直接从adobe官网下载最新版本的Adobe Media Server,由于咱们是在Linux系统搭建的环境,这里选择Download the Linux Update (64-bit)。点击跳转下载页面git
下载完成以后,上传至/use/local路径下,而后就能够开始解压安装了。web
[root@bogon ~]# cd /usr/local/ [root@bogon local]# ls AdobeMediaServer5_x64.tar.gz bin etc games include lib lib64 libexec sbin share src
安装apache
咱们把刚才上传的AdobeMediaServer5_x64.tar.gz先解压bash
tar -zxvf AdobeMediaServer5_x64.tar.gz
解压成功后进入目录服务器
cd AMS_5_0_14_r4006/
执行安装命令:
app
./installAMS
安装的步骤比较多,若是不是特殊需求,能够默认安装(出现提示敲回车就行~)tcp
注意了(敲黑板!~),重点开始了,下面开始详细的安装流程:ide
因为我是CentOS 7.2 64bit版本,因此安装的过程当中出现此提示:
WARNING: Your Linux distribution, RedHat i386_x64 is not supported by this Adobe Media Server installer. Copyright(C) 1993-2013 Adobe Systems Incorporated. All rights reserved. Adobe Media Server 5 for Linux Adobe Media Server 5 will be installed on this machine. You will be asked a series of questions during the install process and will be presented with the defaults for these questions. Support is available at http://www.adobe.com/go/ams To install Adobe Media Server now, press ENTER. To cancel the installation at any time, press Control-C.
大概的意思就是这个FMS版本不支持这个系统版本,安装的时候可能会遇到问题,肯定要继续安装的话敲ENTER键,要随时取消安装,请按Control-C。这仅仅是警告,依然不影响使用。这时候,敲回车继续安装。
这时候会出现一个说明,很长~ 很长~
ADOBE MEDIA SERVER End User License Agreement NOTICE TO USER: THIS END USER LICENSE AGREEMENT (.GREEMENT. GOVERNS INSTALLATION AND USE BY LICENSEES OF THE ADOBE SOFTWARE DESCRIBED HEREIN. LICENSEE AGREES THAT THIS AGREEMENT IS LIKE ANY WRITTEN NEGOTIAT ED AGREEMENT SIGNED BY LICENSEE. BY CLICKING TO ACKNOWLEDGE AGREEMENT TO BE BOUND DURING REVIEW OF AN ELECTRONIC VERSION OF THIS LICENSE, OR DOWNLOADING, COPYING, INSTALLING OR USING THE SOFTWARE, LICENSEE ACCEPTS ALL TH E TERMS AND CONDITIONS OF THIS AGREEMENT. THIS AGREEMENT IS ENFORCEABLE AGAINST ANY PERSON OR ENTITY THAT INSTALLS AND USES THE SOFTWARE AND ANY PERSON OR ENTITY (E.G., SYSTEM INTEGRATOR, CONSULTANT OR CONTRACTOR) THAT INSTALLS OR USES THE SOFTWARE ON ANOTHER PERSON. OR ENTITY. BEHALF. THIS AGREEMENT SHALL APPLY ONLY TO THE SOFTWARE TO WHICH LICENSEE HAS OBTAINED A VALID LICENSE REGARDLESS OF WHETHER OTHER SOFTWARE IS REFERRED TO OR DESCRIBED HEREIN. LICENSEE. RIGHTS UNDER THIS AGREEMENT MAY BE SUBJECT TO ADDITIONAL TERMS AND CONDITIONS IN A SEPARATE WRITTEN AGREEMENT WITH ADOBE THAT SUPPLEMENTS OR SUPERSEDES ALL OR PORTIONS OF THIS AGREEMENT. 1. Definitions 1.1. .dobe. means Adobe Systems Incorporated, a Delaware corporation, 345 Park Avenue, San Jose, California 95110, if subsection 9(a) of this Agreement applies; otherwise it means Adobe Systems Software Ireland Limited, 4-6 Riverwalk Drive, Citywest Business Campus, Saggart D24, Dublin, Republic of Ireland, a company organized under the laws of Ireland and an affiliate and licensee of Adobe Systems Incorporated. 1.2 "Adobe Runtime" means Adobe AIR, Adobe Flash Player and any other future runtimes utilizing Adobe. Flash technology distributed by Adobe or its licensees. 1.3 .uthorized Users.means employees and individual contractors (i.e., temporary employees) of Licensee that (a) develop and/or build applications using the Software; and/or (b) use the Software to deliver Conte nt to end users. 1.4 .omputer.means one or more central processing units in a hardware device (including hardware devices accessed by multiple users through a network that accepts information in digital or similar form and manip ulates it for a specific result based on a sequence of instructions. 1.5 .onnections.means the number of connections over which the client can receive and deliver Content from a single Computer or Virtual Computer where the Software is installed. 1.6 .oncurrent Connections.means the total number of simultaneous Connections from software clients to a specific Computer or Virtual Computer. 1.7 .ontent.means video, audio and/or data files in file formats supported by the Software and may be protected according to the Documentation. 1.8 .ontent Encryption Key. means a cryptographic value for use in encrypting Content for secure distribution and to decrypt encrypted Content for access and use in accordance with the accompanying metadata. 1.9 .tarter Server.means Adobe Media Server Starter, a particular configuration and license of the Software with a limited number of Concurrent Connections. ......
若是你想看的话不妨仔细阅读如下,不过并没什么用。这里我就直接跳过了,按键盘上的Q键或者ctrl+c跳过。以后就会出现:
Do you agree with the license agreement? (y/n):
你赞成许可协议吗?(y/n),这里不用多说了吧,不一样意就退出安装了,输入y赞成,随后就会出现:
Please enter your Adobe Media Server 5 serial number.
请输入您的Adobe Media Server 5序列号。
好吧,其实并非免费的,因此咱们须要一个序列号:1652-5580-8001-8333-2201-1631键入序列号继续1652-5826-9939-6068-8981-7289
Congratulations. You have enabled the Adobe Media Server Extended! Adobe Media Server 5 requires approximately 200MB of disk space. The installer will install Adobe Media Server 5 in the following directory Default [/opt/adobe/ams]:
出现此提示说明序列号可用,他提示咱们安装大约须要200M的磁盘空间,将默认安装在/opt/adobe/ams路径下。若是想要安装在其余路径下,在这里输入路径,默认路径能够直接回车。
我把他安装在/usr/local路径下了,这里输入/usr/local/ams,继续
The administrative user name and password you provide here is required to use the Adobe Media Server Management Console for administration, monitoring, and debugging. Please enter the administrative username:
这里的意思大概就是须要一个用户名和密码,经过Adobe媒体服务器管理控制台进行管理、监控和调试,须要在这里输入用户名,好比:admin,继续
For increased security, enter a password of at least 8 characters. Please enter the administrative password:
接着要求咱们输入密码,我设置的密码是:12345678。密码最少是8位,紧接着重复输入一次密码。
When the Adobe Media Server service is started, the service can be run as a user other than "root". The server would change to this user when the server is started and has acquired its ports. Please enter the user that the Adobe Media Server service will run as Default user [ams]:
接着提示咱们FMS服务以什么身份运行,这里咱们默认就行,直接回车,默认的是【ams】
User "ams" does not exist. Do you want to create it?(y/n) Default [y]:
以后会提示咱们ams用户不存在,要帮咱们建立该用户,接受即可,直接回车,默认是【y】
User "ams" does not exist. Do you want to create it?(y/n) Default [y]:
接着会提示咱们,要建立一个用户所归属的组,这里咱们默认就行,直接回车,默认的是【ams】
Group "ams" does not exist!. This installer will create one ... User "ams" created and added to group "ams" Do you want to install apache? (y/n) Default [y]:
接着提示咱们,组ams不存在,帮咱们建立了该组,建立了ams用户并添加到了该组中。
而后提示咱们是否须要安装apache,这个时候你输入y会自动安装apache。由于我已经安装了nginx,因此,我输入了:n
The Adobe Media Server communicates on the IANA-assigned port of 1935, which is the port most Flash applications expect, and can also communicate on port 80 over RTMPT, HTTP webserver proxy, and for HTTP Dynamic Streaming origin services. Please enter the Adobe Media Server port(s), comma-separated Default [1935,80]:
这个时候是提示咱们设置FMS服务的端口和web服务所须要的端口,这里直接回车,默认便可。
Please enter the port to use for the Admin service. You can only specify one admin port. Default [1111]:
这是设置管理FMS的服务端口。经过这个端口,咱们能够经过FMS提供的flash应用界面登陆并管理FMS系统。 直接回车便可,默认为1111
Do you want the Adobe Media Server service to run as a daemon? (y/n) Default [y]:
问咱们是否要以守护进程的形式运行,固然是OK了,直接回车便可,默认为y
Do you want to start the Adobe Media Server after the installation is done? (y/n) Default [y]:
而后就会询问咱们安装完成以后是否要运行,咱们接受即可,直接回车。
到此,FMS5.0的安装配置已经完成了,接下来就会出现:
----------- Install Action Summary ----------- Installation directory = /usr/local/ams Adobe Media Server Port = 1935,80 Adobe Media Admin Server Port = 1111 Interface (IP address) AMS will listen on = auto-detect Administrative username = admin Administrative password = (suppressed) service owner = ams service user = ams service group = ams Run as daemon = Yes Start Adobe Media Server = Yes Proceed with the installation? (y/n/q):
安装摘要,检查一下安装配置是否正确。若是有误的话,请输入n从新来一遍。若是不想继续安装下去,输入q退出安装。输入y当即安装。咱们输入y,而后耐心等待他安装完成。。。
Installing Adobe Media Server files... Configuring Adobe Media Server... Adding "ams" service. Setting default admin to "ams". Setting autostart for "ams". Server:ams command:start WARNING: Your Linux distribution, RedHat x86_64 is not supported by this installer. 14991 WARNING: AMS requires the maximum number of processes > 32K. Adjust ulimit to match system requirements. NPTL 2.17 Starting Adobe Media Server (please check /var/log/messages) Admin server:amsadmin command:start WARNING: Your Linux distribution, RedHat x86_64 is not supported by this installer. Starting Adobe Media Admin Server (please check /var/log/messages) The Adobe Media Server installation is complete.
The Adobe Media Server installation is complete.
不要忘记开启防火墙端口:
firewall-cmd --permanent --zone=public --add-port=1935/tcp firewall-cmd --permanent --zone=public --add-port=1935/udp firewall-cmd --permanent --zone=public --add-port=1111/tcp firewall-cmd --permanent --zone=public --add-port=1111/udp firewall-cmd --reload
测试推流
使用免费开源推流工具OBS进行推流测试:
设置推流地址为FMS服务器地址,右下角绿色灯亮起表示推流成功!!
接下来咱们进行拉流测试
测试拉流
使用FMS官方的拉流测试工具进行测试,点击直达。
ok,测试成功。
附上一张图,该图右侧为电脑时间,左侧为直播画面的时间。经过obs推流工具实时获取电脑画面实现该测试,因而可知,直播延迟在1-2s之间。注:该测试在局域网中,非外网。