Simple-RTMP-Server 服务器搭建
Simple-RTMP-Server 服务器搭建
1. 服务器镜像获取
- github源码地址
git clone https://github.com/winlinvip/simple-rtmp-server.git
- CSDN镜像地址
git clone https://code.csdn.net/winlinvip/srs-csdn.git
- OSChina镜像
git clone https://git.oschina.net/winlinvip/srs.oschina.git
2. 关闭防火墙和selinux或者开放端口
- 关闭防火墙
# disable the firewall
sudo /etc/init.d/iptables stop
sudo /sbin/chkconfig iptables off
- 使selinux失败
- 编辑配置文件:sudo vi /etc/sysconfig/selinux
- 把SELINUX的值改为disabled:SELINUX=disabled
- 重启系统:sudo init 6
3. 编译系统
./configure --disable-all --with-ssl --with-hls --with-nginx --with-ffmpeg --with-transcode
make && sudo make install
安装命令会将SRS默认安装到/usr/local/srs
中,可以在configure
时指定其他目录,譬如./configure --prefix=
pwd/_release
可以安装到当前的_release
目录(可以不用sudo安装,直接用make install即可安装)
4. 建立启动服务
4.1 建立软连接
sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs
备注:若SRS安装到其他目录,将/usr/local/srs替换成其他目录。
备注:也可以使用其他的名称,譬如/etc/init.d/srs,可以任意名称,启动时也用该名称。
4.2 添加服务
#centos 6
sudo /sbin/chkconfig --add srs
或者
#ubuntu12
sudo update-rc.d srs defaults
4.3 使用init.d脚本管理SRS
查看SRS状态:
/etc/init.d/srs status
启动SRS:
/etc/init.d/srs start
停止SRS:
/etc/init.d/srs stop
重启SRS:
/etc/init.d/srs restart
Reload SRS:
/etc/init.d/srs reload
5. 启动分发hls(m3u8/ts)的nginx
sudo ./objs/nginx/sbin/nginx
6. 编写SRS配置文件
将以下内容保存为文件,譬如conf/transcode2hls.audio.only.conf,服务器启动时指定该配置文件(srs的conf文件夹有该文件)。
# conf/transcode2hls.audio.only.conf
listen 1935;
max_connections 1000;
http_stream {
# whether http streaming service is enabled.
# default: off
enabled on;
# the http streaming port
# @remark, if use lower port, for instance 80, user must start srs by root.
# default: 8080
listen 8080;
# the default dir for http root.
# default: ./objs/nginx/html
dir ./objs/nginx/html;
}
vhost __defaultVhost__ {
hls {
enabled on;
hls_path ./objs/nginx/html;
hls_fragment 10;
hls_window 60;
}
transcode {
enabled on;
ffmpeg ./objs/ffmpeg/bin/ffmpeg;
engine ff {
enabled on;
vcodec copy;
acodec libaacplus;
abitrate 45;
asample_rate 44100;
achannels 2;
aparams {
}
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
}
}
}
备注:这个配置使用只转码音频,因为视频是h.264符合要求
7. 启动SRS
./objs/srs -c conf/transcode2hls.audio.only.conf
或者使用服务进行启动
8. 启动推流编码器
使用FFMPEG命令推流:
for((;;)); do \
./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
-vcodec copy -acodec copy \
-f flv -y rtmp://192.168.1.170/live/livestream; \
sleep 1; \
done
或使用FMLE推流:
FMS URL: rtmp://192.168.1.170/live
Stream: livestream
生成的流地址为:
- RTMP流地址为(FMLE推流无HLS地址):rtmp://192.168.1.170/live/livestream
- 转码后的RTMP流地址为:rtmp://192.168.1.170/live/livestream_ff
- 转码后的HLS流地址为: http://192.168.1.170/live/livestream_ff.m3u8
备注:因为FMLE推上来的音频有问题,不是aac,所以srs会报错(当然啦,不然就不用转码了)。这个错误可以忽略,srs是说,rtmp流没有问题,但是无法切片为hls,因为音频编码不对。没有关系,ffmpeg会转码后重新推一路流给srs。
备注:如何只对符合要求的流切hls?可以用vhost。默认的vhost不切hls,将转码后的流推送到另外一个vhost,这个vhost切hls。
9. 观看RTMP流
- RTMP流地址为:rtmp://192.168.1.170/live/livestream_ff
- 播放器:VLC
- 或者:
http://winlinvip.github.io/srs.release/trunk/research/players/srs_player.html?vhost=defaultVhost&autostart=true&server=192.168.1.170&app=live&stream=livestream_ff
- HLS流地址为: http://192.168.1.170/live/livestream_ff.m3u8
- 播放器VLC
- 或者
- http://winlinvip.github.io/srs.release/trunk/research/players/jwplayer6.html?vhost=defaultVhost&hls_autostart=true&server=192.168.1.170&app=live&stream=livestream_ff
10. 手机端查看
10.1 Android
<video width="640" height="360"
autoplay controls autobuffer
src="http://127.0.0.1/live/livestream.m3u8"
type="application/vnd.apple.mpegurl">
</video>
10.2 IOS
http://127.0.0.1/live/livestream.m3u8
Simple-RTMP-Server 服务器搭建的更多相关文章
- Simple Rtmp Server的安装与简单使用
Simple Rtmp Server是一个国人编写的开源的RTMP/HLS流媒体服务器. 功能与nginx-rtmp-module类似, 可以实现rtmp/hls的分发. 有关nginx-rtmp-m ...
- OSX安装nginx和rtmp模块(rtmp直播服务器搭建)
1.安装Homebrew,执行命令 1 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ma ...
- centos7 RTMP直播服务器搭建
首先需要下载 nginx-1.8.1 : http://nginx.org/download/nginx-1.8.1.tar.gz nginx-rtmp-module : https://github ...
- 旧电脑做服务器--第一篇 sql server 服务器搭建
背景:旧电脑为2015年的老电脑,联系G50系列,目前键盘鼠标操作都有问题,键盘按键和鼠标左键莫名奇妙变成右击,屏幕显示也是大颗粒.但是配置还可以,16GB内存+256GB三星固态硬盘.所以想搭建作为 ...
- VisualSVN Server 服务器搭建 和 TortoiseSVN的配置和使用方法
摘自:https://blog.csdn.net/litaoshoujiao/article/details/8526136 一.VisualSVN Server的配置和使用方法[服务器端] 安装好V ...
- git server服务器搭建
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579 ...
- Windows Server 2003搭建邮件服务器
Windows Server 2003搭建邮件服务器 由于Windows Server 2003默认是没有安装我们搭建邮件服务器所需要的POP3和SMTP服务的,因此需要我们自己来安装.方法如下: 1 ...
- rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
关键词:Nignx(http服务器):rtmp,hls(流媒体服务) 前言:感谢开源,感谢战斗民族.现在在做流媒体服务的一些工作,流媒体服务器搭建的网上教程多入牛毛,但是细细查看,发现很多同志贴上来的 ...
- win10下一分钟快速搭建rtmp推流服务器
为了让大家少踩笔者踩过的坑,目前将工作中搭建rtmp推流服务器的步骤总结如下: 步骤1: 下载 nginx 1.7.11.3 Gryphon 下载链接: http://nginx-win.ecsds. ...
- 使用FileZilla Server轻松搭建个人FTP服务器
Linux平台下快速搭建FTP服务器 服务器FTP Server环境搭建 针对以上遇到的问题的解决方案如下: 1)如何上传文件到云服务器上 关于这个问题,我首先想到的是使用FileZ ...
随机推荐
- Android(Xamarin)之旅(四)
这么晚了,可能也因为一点事情,就说打开博客园看看,结果 http://www.cnblogs.com/mindwind/p/5125248.html 这篇文章瞬间吸引了我.暗暗的回想一下,十年之后,我 ...
- (转)字符编码笔记:ASCII,Unicode和UTF-8
字符编码笔记:ASCII,Unicode和UTF-8 访问地址:http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html
- hdu 1086 You can Solve a Geometry Problem too
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- MQ安装配置
(1)执行接受许可脚本: ./mqlicense.sh –accept (2) 安装 WebSphere MQ for Linux 服务器: [root@localhost mq]# rpm ...
- 10. Software, Software Engineering, water fall (瀑布模型),Code Complete等名词的来源
①.Software-软件”一词是20世纪60年代才出现的,软件Software——1958年由贝尔实验室的著名统计学家John Tukey 提出软件与硬件一起构成完整的计算机系统,它们是相互依存,缺 ...
- 斯坦福第十六课:推荐系统(Recommender Systems)
16.1 问题形式化 16.2 基于内容的推荐系统 16.3 协同过滤 16.4 协同过滤算法 16.5 矢量化:低秩矩阵分解 16.6 推行工作上的细节:均值归一化 16.1 问题形式 ...
- io多路复用,select,笔记
一下代码,是摘自大王的博客,(http://www.cnblogs.com/alex3714/)我自己有加了些注释. 1 2 3 #_*_coding:utf-8_*_ 4 5 __author__ ...
- 拉格朗日乘子法和KKT条件
拉格朗日乘子法(Lagrange Multiplier)和KKT(Karush-Kuhn-Tucker)条件是求解约束优化问题的重要方法,在有等式约束时使用拉格朗日乘子法,在有不等约束时使用KKT条件 ...
- 解决"java.lang.ClassNotFoundException: com.mysql.jdbc.Driver"
按照以前的老方法,写Java的主程序通过JDBC来连MySQL. //1: import java.sql.*; import java.sql.*; public class JDBC_Driver ...
- FIM相关报错汇总
1.错误1:FIM在修改MA名字的时候报错: The management agent cannot be deleted or renamed because the working directo ...