obs+nginx+rtmp+web实现视频直播网站

本文详细介绍如何使用OBS、NGINX+RTMP模块和video.js构建视频直播系统,包括服务器配置、OBS推送流设置及H5端视频流播放。

项目简介:视频直播网站由三个部分构成:1.推流端 2.服务器 3.拉流端。在该项目中,推流端用OBS完成,服务器由NGINX+RTMP模块完成,拉流端使用video.js完成。

一、开发环境:
  • 推流端:系统:UBUNTU 16.04 工具:obs
  • 服务器:系统: UBUNTU 16.04 工具:NGINX+RTMP
  • 拉流端:系统:WINDOWS 10 工具:H5
二、 构建服务器

服务器由NGINX+RTMP构成。NGINX是HTTP服务器,RTMP是附加模块。
其中NGINX我选择的是用源码编译方式进行安装,因为这种方式可以自定义安装指定的模块以及最新版本。
首先配置各项依赖库。

下载 nginx 1.7.11.3 Gryphon
下载链接: http://nginx-win.ecsds.eu/download/nginx 1.7.11.3 Gryphon.zip
下载完成后解压;
将解压后的目录名:
nginx 1.7.11.3 Gryphon
改成:
nginx-1.7.11.3-Gryphon

三、 下载服务器状态检查程序 stat.xsl

https://github.com/arut/nginx-rtmp-module/
将nginx-rtmp-module-master.zip解压后复制到目录:nginx-1.7.11.3-Gryphon下,
保证stat.xls的目录为:
nginx-1.7.11.3-Gryphon\nginx-rtmp-module\stat.xsl(注意地址必须为nginx-rtmp-module)

四、 配置文件 conf\nginx-win-rtmp.conf 内容如下:
#user  nobody;
# multiple workers works !
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  8192;
    # max value 32768, nginx recycling connections+registry optimization = 
    #   this.value * 20 = max concurrent connections currently tested with one worker
    #   C1000K should be possible depending there is enough ram/cpu power
    # multi_accept on;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4000;
        application live {
             live on;
        }
    }
}

http {
    #include      /nginx/conf/naxsi_core.rules;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  'remoteaddr:remote_port - remoteuser[time_local] "request" '     #                  'status bodybytessent"http_referer" '
    #                  '"httpuseragent""http_x_forwarded_for"';

    #access_log  logs/access.log  main;

#     # loadbalancing PHP
#     upstream myLoadBalancer {
#         server 127.0.0.1:9001 weight=1 fail_timeout=5;
#         server 127.0.0.1:9002 weight=1 fail_timeout=5;
#         server 127.0.0.1:9003 weight=1 fail_timeout=5;
#         server 127.0.0.1:9004 weight=1 fail_timeout=5;
#         server 127.0.0.1:9005 weight=1 fail_timeout=5;
#         serve
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值