zoukankan      html  css  js  c++  java
  • nginx搭建简单直播服务器

    1、下载模块(nginx-rtmp-module)

    1 cd /data/nginx
    2 yum install git3 git clone https://github.com/arut/nginx-rtmp-module.git

    2、安装nginx:

    1 yum install gcc make pcre-devel openssl-devel 
    2 wget http://nginx.org/download/nginx-1.15.0.tar.gz 
    3 tar xf nginx-1.15.0.tar.gz
    4 cd nginx-1.15.0
    5 ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module     
    6 make && make install

    3、修改nginx配置文件

     1 rtmp {      
     2     server {   
     3         listen 1935;                               #监听端口    
     4         chunk_size 4000;                           #包大小,默认4096,值越大,CPU越低,不能小于128
     5 
     6         application hls {                          #rtmp推流请求路径 
     7             live on;                               #开启直播
     8             hls on;                                #开启hls
     9             hls_path /usr/share/nginx/html/hls;    #rtmp推流文件存放路径,要可读可写的权限
    10             hls_fragment 5s;                       #每个TS文件包含5秒的视频内容
    11         }   
    12     }   
    13 } 

    4、推流

    ffmpeg推流

    推流:
    ffmpeg -re -i  /path/file.mp4   -vcodec copy - acodec copy -f flv rtmp://192.168.4.11:1935/hls

    obs推流

    下载obs软件,点击设置,URL:rtmp://IP:1935/hls,流名称:房间号

    新建VLC本地视频,后开始推流,有多种推流来源(本地视频,图像、外接设备),查看/usr/local/nginx/html/hls目录的文件

    5、观看直播(拉流)

    用支持HTML5浏览器播放(Microsoft Edge)

    cat /usr/local/nginx/html/test.html 
    <video>
        <source src="http://192.168.4.11/hls/test.m3u8"/>
        <p class="warning">Your browser does not support HTML5 video.</p>
    </video>

    用软件VLC播放

    流地址:http://192.168.4.11/hls/test.m3u8
  • 相关阅读:
    比特币安全
    vxworks 的 socket, thread, 信号量模型
    libx264 安卓编译
    优秀的gdb图形化前端调试器
    gdb revert, Go to previous line in gdb
    进藏体会,高原反应
    将 ssh (security shell) 移植到 vxworks
    Pcap4J实现抓包器
    有时候有些服务类的网站就是不走心啊
    都市夜未眠
  • 原文地址:https://www.cnblogs.com/wuhg/p/12731597.html
Copyright © 2011-2022 走看看