搭建直播平台

                                       搭建直播平台

1、下载nginx-rtmp-module:

1)nginx-rtmp-module的官方github地址:https://github.com/arut/nginx-rtmp-module

 2)使用git下载nginx-rtmp-module

克隆: git clone https://github.com/arut/nginx-rtmp-module.git 

将nginx-rtmp-module下载设定的linux路径中一般情况下我是放在了(cd usr/local/src/)。

2、安装nginx:

1)首先查看你是否安装了nginx 如果没有安装请进行安装nginx  推荐安装路径

2)如果已经安装了配置以下内容

进入安装的版本nginx下 (我的是1.8.1如果版本不一样请修改)

            cd nginx-1.8.1

nginx-1.8.1执行下面两个命令关联已下载的nginx-rtmp-module

./configure --prefix=/usr/local/nginx  --add-module=../nginx-rtmp-module  --with-http_ssl_module

make && make install 

本次默认安装目录为:/root, add-module为下载的nginx-rtmp-module文件路径。

    3)  如果安装的时候报错没有安装openssl,需要执行命令:

yum -y install openssl openssl-devel 

3、修改nginx配置文件:

进入nginx.conf配置文件内:vi /usr/local/nginx/conf/nginx.conf  


修改或加入以下内容:

[php] 

  1. rtmp {    
  2.     server {     
  3.         listen 1935;  #监听的端口  
  4.         chunk_size 4000;    
  5.         application hls {  #rtmp推流请求路径  
  6.             live on;    
  7.             hls on;    
  8.             hls_path /usr/local/nginx/html/hls;  #自己的推送路径也就是访问的路径
  9.             hls_fragment 5s;    
  10.         }    
  11.     }    
  12. }  

同配置内

hls_path需要可读可写的权限。

修改http中的server模块:

[php] 

  1. server {  
  2.     listen       81;  
  3.     server_name  localhost;  
  4.   
  5.     #charset koi8-r;  
  6.   
  7.     #access_log  logs/host.access.log  main;  
  8.   
  9.     location / {  
  10.         root   /usr/local/nginx/html;  #自己配置路径
  11.         index  index.html index.htm;  
  12.     }  
  13.   
  14.     #error_page  404              /404.html;  
  15.   
  16.     # redirect server error pages to the static page /50x.html  
  17.     #  
  18.     error_page   500 502 503 504  /50x.html;  
  19.     location = /50x.html {  
  20.         root   html;  
  21.     } 

然后启动nginx:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf    

 

rtmp的参数可参考:https://github.com/arut/nginx-rtmp-module/wiki

4,完成后安装obs

    1)可安装在我们的电脑上

     安装会出现bug 自己调试 (安装上就行)

     2)安装好后我们开始配置obs

     第一步 如上图点击进入

     

 

     第二步  修改编码可修改也可不修改

    

   

    第三步  广播设定                 

   

    第四步 后面的你们自定义配置吧!不配置也可以

   

 

5,前面的完成后我们再场景配置

     选择一个即可配置可视频(视屏捕捉设备)也可桌面的

 

 

6,完成后我们开始串流

   会出现如下形式(此处我的场景配置是显示器获取

 

7、好了接下来我们可以观看直播(拉流)

观看直播就比较简单了,

在linux上创建hls文件也可是其他的文件夹

书写一个index.php文件

内容可如下:

[php] 

  1. <video>    
  2.     <source src="http://xxx:81/hls/test.m3u8"/>    
  3.     <p class="warning">Your browser does not support HTML5 video.</p>    
  4. </video>  

然后就可以简单的使用h5的vedio标签就可以观看了。

可以访问http://xxx:81/hls/mystream.m3u8来观看直播,其中xxx为你的服务器IP地址,

 

 

1,下载nginx-rtmp-module:

nginx-rtmp-module的官方github地址:https://github.com/arut/nginx-rtmp-module

1)进到一个路径下存储(一般我存到 cd /usr/local/src/ ),使用git下载nginx-rtmp-module

2) 命令执行:git clone https://github.com/arut/nginx-rtmp-module.git 

Github下载地址:https://github.com/XLAccount/MiaoBo 项目详解地址:http://www.code4app.com/blog-843201-350.html 快速集成RTMP的视频推流教程:http://www.code4app.com/blog-843201-315.html ffmpeg常用命令操作:http://www.code4app.com/blog-843201-326.html #关于IJKMediaFramework/IJKMediaFramework.h找不到的问题,下载后直接拉到项目中即可 下载地址:https://pan.baidu.com/s/1boPOomN 密码::9yd8 #BUG修复: 解决登录程序偶尔崩溃,修复轮播图片和页面控制器叠加等问题,修复新浪授权登录 (2016.9.7) 解决程序运行中偶尔崩溃问题,解决连续下拉刷新崩溃问题,优化代码 (2016.9.8) 优化直播页面,减少不必要的性能消耗,增加用户体验 (2016.9.11) 适配5s以上的机型除了6sPlus和6Plus延迟较大外,其余延迟都较小,网速好的话可以忽略不计 (2016.9.12) 新版本极大优化程序性能,修复关注数据异常等小问题,重新布局热门页面,减少因反复加载带来的性能消耗 (2016.9.13) 增加个人中心页面,采用下拉放大图片 ➕ 波纹效果 (2016.9.14) ![image text](https://github.com/XLAccount/ALLGIFS/blob/master/psb.gif) 展示图片 ![image](https://github.com/XLAccount/ALLGIFS/blob/master/psb-1.gif) 展示图片 ![image text](https://github.com/XLAccount/ALLGIFS/blob/master/psb-2.gif) 展示图片 ![image text](https://github.com/XLAccount/ALLGIFS/blob/master/psb-3.gif) 展示图片 感谢大神Monkey_ALin http://www.jianshu.com/users/9723687edfb5/latest_articles 的demo支持
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值