nginx 搭建 rtmp

 

 

 

  • 1. 解压 nginx 1.7.11.3 Gryphon.zip -> 解压 nginx-rtmp-module-master.zip
  • 将 nginx-rtmp-module-master 文件名修改为 nginx-rtmp-module 并移动到 nginx 1.7.11.3 Gryphon
  • 在 nginx 1.7.11.3 Gryphon/config 里面新建文件 nginx.conf 内容如下:
    • nginx.conf
      worker_processes  2;
      
      events {
          worker_connections  8192;
      }
      
      rtmp {
          server {
              listen 1935;#监听端口,若被占用,可以更改
              chunk_size 4000;#上传flv文件块儿的大小
              application live { #创建一个叫live的应用
                   live on;#开启live的应用
                   allow publish 127.0.0.1;#
                   allow play all;
              }
          }
      }
      
      http {
          include       mime.types;
          default_type  application/octet-stream;
      
          sendfile        off;
          #tcp_nopush     on;
      
          server_names_hash_bucket_size 128;
      
      ## Start: Timeouts ##
          client_body_timeout   10;
          client_header_timeout 10;
          keepalive_timeout     30;
          send_timeout          10;
          keepalive_requests    10;
      ## End: Timeouts ##
      
          server {
              listen       81;
              server_name  localhost;
      
              location / {
                  root   html;
                  index  index.html index.htm;
              }
          }
      
      
      }

       

  •  到这就完了,下面是一些常用的命令:
    • 测试 配置的有没有问题:nginx.exe -t
    • 启动: start nginx
    • 停止:nginx.exe -s stop || nginx.exe -s quit (这个停止会保存一些运行的信息,有序停止) || taskkill /f /im  nginx.exe
    • 重启:nginx.exe -s reload
    • 看版本:nginx -v
  • 最后测试:用 obs 往 rtmp://127.0.0.1:1935/live 这个地址推视频,然后用 vlc 打开这个地址:rtmp://192.168.50.98:1935/live
    • 注意不同的设备给个不同的地址,免的 vlc 播放不了,如  rtmp://127.0.0.1:1935/live1、 rtmp://127.0.0.1:1935/live2 ...
posted @ 2024-05-31 15:59  封兴旺  阅读(14)  评论(0编辑  收藏  举报

联系方式: 18274305123(微信同号)