找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 122|回复: 0

nginx直播http-flv+hls+rtmp演示.zip

[复制链接]

2万

主题

128

回帖

10万

积分

管理员

积分
105864
发表于 2021-9-23 12:50:29 | 显示全部楼层 |阅读模式 IP:山东省青岛市 移动

登录后更精彩...O(∩_∩)O...

您需要 登录 才可以下载或查看,没有账号?立即注册

×
nginx直播http-flv+hls+rtmp演示.zip








网上很多文章都是介绍nginx的源码编译,但是首先我得看到效果啊1、解压到目录,比如D:\nginx
2、运行服务器软件: 双击start.bat,任务管理器里面有2个nginx.exe就对了。
3、运行推送: 打开ffmpeg下的推送桌面.bat,成功的话360显示ffmpeg.exe直接有流量了,nginx.exe也有流量了
4、本地打开浏览器或者客户端:(VLC或播放器) rtmp: VLC或者打开rtmp播放器,输入地址.(浏览器不支持苹果) http-flv:VLC或者打开rtmp播放器,输入地址.(浏览器不支持苹果) HLS:苹果浏览器打开m3u8地址







网上很多文章都是介绍nginx的源码编译,但是首先我得看到效果啊,所以写下这篇文章:


话不多说,直接上效果图:

1、解压到目录,比如D:\nginx
2、运行服务器软件:
     双击start.bat,任务管理器里面有2个nginx.exe就对了。


3、运行推送:
     打开ffmpeg下的推送桌面.bat,成功的话360显示ffmpeg.exe直接有流量了,nginx.exe也有流量了


4、本地打开浏览器或者客户端:(VLC或播放器)
     rtmp:  VLC或者打开rtmp播放器,输入地址.(浏览器不支持苹果)
     http-flv:VLC或者打开rtmp播放器,输入地址.(浏览器不支持苹果)
     HLS:苹果浏览器打开m3u8地址




5、说明:
     推送地址rtmp://127.0.0.1:1935/live/xiao
     接收端地址:
     本地rtmp 接收:    rtmp://127.0.0.1:1935/live/xiao
     本地http-flv 接收:    http://127.0.0.1:8002/live?app=live&port=1935&stream=xiao
     本地HLS 接收:          http://127.0.0.1:8002/hls/xiao.m3u8


     conf\nginx.conf可以修改配置
     比较关键的值:
     rtmp:1935代表端口号
     application live:代表地址里面的live
     gop_cache off;关闭可以减少延迟           


     hls_playlist_length 4s; HLS设置
     hls_fragment 1s;#一个ts 文件的时长1s


conf\nginx.conf配置文件:


worker_processes  1;
events {
    worker_connections  10240;
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp{#相当于数据输入
    out_queue 4096;
    out_cork 8;
    max_streams 128;
    timeout 15s;
    drop_idle_publisher 15s;
    log_interval 5s;
    log_size 1m;
    server{
     listen 1935;
     application live{
         live on;
         gop_cache off;
      }
     application hls{
             hls_playlist_length 4s;
              hls_fragment 1s;#一个ts 文件的时长1s
      live on;
      hls on;
      hls_path html/hls;
   


    }
     application dash{
       live on;
       dash on;
       dash_path html/dash;
     }
   
    }
}
http {#相当于数据输出
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8002;
        server_name  127.0.0.1;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location /live{
            flv_live on;
            chunked_transfer_encoding  on;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
        }
        location /hls{
            types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
             }
             root html;
             add_header 'Cache-Control' 'no-cache';
        }
        
         location /dash {
                root html/dash;
                add_header 'Cache-Control' 'no-cache';
        }
        
        location /stat {
                #configuration of push & pull status
                  rtmp_stat all;
                  rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
          root /usr/local/nginx/nginx-http-flv-module;
        }


        location /control {
                rtmp_control all; #configuration of control module of rtmp
        }   
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {
        listen       8003;
        server_name  127.0.0.1;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}


demo下载地址:

游客,如果您要查看本帖隐藏内容请回复



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|IOTsec-Zone|在线工具|CTF WiKi|CTF平台汇总|CTF show|ctfhub|棱角安全|rutracker|攻防世界|php手册|peiqi文库|CyberChef|猫捉鱼铃|手机版|小黑屋|cn-sec|分享屋 ( 鲁ICP备2021028754号 )

GMT+8, 2024-5-21 21:14

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表