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 ...
随机推荐
- mybatis 打印sql 语句
拦截器 package com.cares.asis.mybatis.interceptor; import java.text.DateFormat; import java.util.Date; ...
- 模拟Linux的shell
在学习了Linux的进程控制之后,学习了fork函数和exec函数族,通过这些个函数可以简单的实现一份shell,就是实现一份命令行解释器,当然是简单版的,实现功能如下 能执行普通的命令如ls ,ps ...
- CodeForces 742B Batch Sort
B. Batch Sort time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Json&Razor&控制器
JsonJson 属于JavaScript所以要书写在<script></script>中1.语法规则: 1.1:键值对 1.2:逗号分隔 1.3:花括号保存对象 1.4:方括 ...
- C# Winform程序获取外网IP地址
string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了 Uri uri = new Uri(strUrl); ...
- step by step 之餐饮管理系统四(日志模块实现)
三天前基本上把数据库表设计的文档写好,今天想到了一个问题,还要再加几个表,一个是log表,用来记录系统日志,另外再加几个字典表,一些需要配置的数据但又不好放在像xml文件里面的数据可以放在这些字典表里 ...
- 【收藏】android WebView总结
来自:http://blog.csdn.net/chenshijun0101/article/details/7045394 浏览器控件是每个开发环境都具备的,这为马甲神功提供了用武之地,window ...
- 【07_226】Invert Binary Tree
Invert Binary Tree Total Accepted: 54994 Total Submissions: 130742 Difficulty: Easy Invert a binary ...
- 动态时间归整/规整/弯曲(Dynamic time warping,DTW)
动态时间规整DTW 在日常的生活中我们最经常使用的距离毫无疑问应该是欧式距离,但是对于一些特殊情况,欧氏距离存在着其很明显的缺陷,比如说时间序列,举个比较简单的例子,序列A:1,1,1,10,2, ...
- web标准:img图片在ie6下显示空白的bug解决方案
在进行页面的DIV+CSS排版时,遇到IE6(当然有时Firefox下也会偶遇)浏览器中的图片元素img下出现多余空白的问题绝对是常见的对于该问题的解决方法也是“见机行事”. 1.将图片转换为块级对象 ...