基于obs+nginx-rtmp-module搭建自己直播的系统
前言
一句唠叨,工欲善其事,必先利其器,在程序员的工作里,搭建各种环境往往花费过多不必要的时间,这里建议搭建服务端环境时,尽量避开win、macos这种系统,个人比较推崇centos。
操作
下面以centos环境为例(macos安装nginx运气不好会让人崩溃)。
安装nginx及nrm模块
请提前确保已经安装gcc、g++、zlib、pcre、openssl(如果编译nginx过程中仍显示缺少已安装过的库,可以在下方给我留言一起探讨问题)。
cd /usr/local
wget http://nginx.org/download/nginx-1.12.2.tar.gz #下载nginx
tar -xzvf nginx-1.12.2.tar.gz #解压nginx
wget https://codeload.github.com/arut/nginx-rtmp-module/legacy.tar.gz/master #下载nginx-rtmp-module
tar -xzvf arut-nginx-rtmp-module-v1.2.1-0-g791b613.tar.gz #解压nginx-rtmp-module
mv ./arut-nginx-rtmp-module-v1.2.1-0-g791b613 ./NRM #改个名
./configure --add-module=/usr/local/NRM --prefix=/usr/local/nginx --with-debug
make
make install #至此nginx安装完成
/usr/local/nginx/sbin/nginx #启动nginx
/usr/local/nginx/sbin/nginx -V #查看nginx安装模块信息和版本号
配置nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
######################ADD RTMP################
rtmp { #RTMP服务
server {
listen 1935; #//服务端口
chunk_size 4096; #//数据传输块的大小
application vod {
play /opt/video/vod; #//视频文件存放位置,自定义
}
application live { #第一处添加的直播字段
live on;
}
application push{
live on; #开启直播
push rtmp://<自己公网ip,没有可以填localhost本地玩一下>/live; #推流到上面的直播应用
}
}
}
#####################ADD RTMP################
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#################################################
location /stat { #第二处添加的location字段。
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl { #第二处添加的location字段。
root /usr/local/NRM/; #一定要填对
}
##################################################
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
完成以上步骤后,保存,执行nginx -s reload重新加载。
在/stat可以看到如下信息:
推流端配置
下载并安装obs,点击下图设置(这里我觉得该有个马赛克!!)
并填入如下url(换成自己的ip即可)
点击开始推流,进行推流,可以看到/stat有数据的变化信息。
拉流端
这时候可以选用任意一款支持rtmp的播放器,填入rtmp:///live观看直播。
总结
这里的架构虽然比较简单,推流、拉流,中间通过nginx转发,却也给直播入门提供一个清晰的感官上的体验。HAVE FUN!
基于obs+nginx-rtmp-module搭建自己直播的系统的更多相关文章
- centos7+nginx+rtmp+ffmpeg搭建流媒体服务器(保存流目录与http目录不要随意配置,否则有权限问题)
搭建nginx-http-flv-module升级代替rtmp模块,详情:https://github.com/winshining/nginx-http-flv-module/blob/master ...
- Ubuntu中使用Nginx+rtmp模块搭建流媒体视频点播服务
1. 背景 不知不觉笔者来到流媒体部门已经一年半多了,积攒了不少的流媒体知识,但平时工作也比较忙,很少进行总结性的梳理,最近准备花几个周末时间写一个流媒体系列的实践文章,也算是给自己做总结的同时帮助有 ...
- (转)Nginx+rtmp+ffmpeg搭建流媒体服务器
(1)下载第三方扩展模块nginx-rtmp-module # mkdir module && cd module //创建一个存放模块的目录 # wget https://githu ...
- 使用 nginx 和 rtmp 插件搭建视频直播和点播服务器
使用 nginx 和 rtmp 模块 ,可以很容易地搭建一个视频直播和点播服务器出来. 首先,看一下最经典的参考文献: How to set up your own private RTMP serv ...
- Nginx+rtmp+ffmpeg 搭建推流服务器
1. 安装nginx服务器 1.1 clone $ brew tap denji/homebrew-nginx 1.2 安装 $ brew install nginx-full --with-rtmp ...
- centos7+nginx+rtmp+ffmpeg搭建流媒体服务器
1.安装前需要的工具 #net-tool 查本地IP #wget 下载安装包 #unzip 解压zip包 #gcc gcc-c++ perl 编译软件包用 yum install -y net-too ...
- Ubuntu中使用Nginx+rtmp搭建流媒体直播服务
一.背景 本篇文章是继上一篇文章<Ubuntu中使用Nginx+rtmp模块搭建流媒体视频点播服务>文章而写,在上一篇文章中我们搭建了一个点播服务器,在此基础上我们再搭建一个直播服务器, ...
- ffmpeg,rtmpdump和nginx rtmp实现录屏,直播和录制
公司最近在做视频直播的项目,我这里分配到对直播的视频进行录制,录制的方式是通过rtmpdump对rtmp的视频流进行录制 前置的知识 ffmpeg: 用于实现把录屏工具发出的视频和音频流,转换成我们需 ...
- Linux-Nginx+rtmp+ffmpeg搭建流媒体服务器
Nginx+rtmp+ffmpeg搭建流媒体服务器 说明: nginx搭建流媒体服务需要用到 nginx-rtmp-module 模块 具体操作步骤: 安装nginx (1)下载第三方扩展模块ngin ...
随机推荐
- Oracle sql 优化の索引监控
1.监视索引是否使用 除了主键是完整性约束而自动变为索引外,创建普通索引的目的就是为了提高查询速度,如果我们创建了索引而没有被使用,那么这些不被使用的索引将起到阻碍性能的作用. 语法: --检查某个索 ...
- Python学习-41.Python中的断言
先来点题外话: 在现代编程开发中,TDD(测试驱动开发)变得越来越流行(PS:DDD(领域驱动开发)也是,但两者并不冲突,就像面向过程和面向对象).而作为TDD的根本——单元测试也是越来越重要,单元测 ...
- NetCore入门篇:(八)Net Core项目使用Controller之三
一.简介 1.本节主要说明入参的几种接收方式 二.不限定模式 1.定义一个id入参与一个model入参. 2.get\post分别查看访问效果. api代码 public class OneContr ...
- NetCore入门篇:(七)Net Core项目使用Controller之二
一.简介 1.说明Post,Get定义的区别. 2.说明如何路由定义. 二.Get.Post定义 1.api不定义访问方式时,同时支持get 和 post.如果定义某种方式,则仅支持某种方式.具体看代 ...
- devexpress 严重性 代码 说明 项目 文件 行 禁止显示状态 错误 “lc.exe”已退出,代码为 -1。
将licensens.licx删除,就能正常运行
- .net Aspose.pdf 转html 去除版权
时光偷走的,永远都是我们眼皮底下看不见的珍贵. 1. 资源文件 a) Aspose.pdf.18.12.0.nupkg 链接:https://pan.baidu.com/s/171_OWOf ...
- f.lux在linux下的安装和使用
安装还是蛮容易的~只是装完后在白天色温没什么变化就一直以为没有装成功 https://justgetflux.com/linux.html 这里下载,解压后 安装好以后xflux -l (经纬度) 就 ...
- Python廖雪峰学习笔记——操作文件和目录
查看当前目录的绝对路径: >>>os.path.abspath('.') # 在某个目录下创建一个新目录, # 首先把新目录的完整路径表示出来: >>> os.pa ...
- Mysql的Text和Blob的比较
MySQL存在text和blob: (1)相同 在TEXT或BLOB列的存储或检索过程中,不存在大小写转换,当未运行在严格模式时,如果你为BLOB或TEXT列分配一个超过该列类型的最大长度的值,值被截 ...
- Minimax-486. Predict the Winner
Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from eith ...