加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx – 通过http流式传输RTMP

发布时间:2020-12-13 21:02:05 所属栏目:Nginx 来源:网络整理
导读:我正在尝试使用Nginx-rtmp建立流媒体服务.配置文件是 rtmp { server { listen 1935; chunk_size 4000; # video on demand for flv files application vod { play /var/flvs; } # video on demand for mp4 files application vod2 { play /var/mp4s; } }} 我

我正在尝试使用Nginx-rtmp建立流媒体服务.配置文件是

    rtmp {
    server {
        listen 1935;

        chunk_size 4000;

        # video on demand for flv files
        application vod {
            play /var/flvs;
        }

        # video on demand for mp4 files
        application vod2 {
            play /var/mp4s;
        }
    }
}

我希望流媒体服务通过http而不是rtmp.最终我们希望客户端使用https连接到代理服务器,然后代理服务器使用rtmp与流服务器通信.我现在正在使用HTTP进行测试.所以我使用以下配置设置了HAProxy:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    #tune.ssl.default-dh-param 2048 

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information,see ciphers(1SSL). This list is from:
    #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
    ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
    ssl-default-bind-options no-sslv3

defaults
    log global
    mode    tcp
    option  httplog
    option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http


frontend rtmp-80
        bind *:80
        default_backend rtmp-over-http

backend rtmp-over-http
        server media01 127.0.0.1:1935 check maxconn 200 

我可以在VLC播放器中使用uri of rtmp:// the_ip:1935 / vod2 / gua.mp4访问流媒体服务.
但无论我尝试什么,当我尝试使用http://the_ip:80/vod2/gua.mp4访问流媒体时,它都不起作用.

这有可能吗?

非常感谢!

最佳答案
那么,视频客户端(在你的情况下是VLC播放器)必须知道它试图从哪个协议读取流.所以简而言之,没有.您必须修改客户端才能让它知道它实际上是在接收RTMP内容而不是HTTP.

另外,您可以尝试将端口80用于RTMP服务器吗?但一般来说,窃取HTTP的端口并不是一个好主意,但视频确实会通过端口80传输(但不使用HTTP的协议).

现在,如果您想通过HTTP的主体(使用您的服务器代理)传递RTMP内容,客户端还需要将传入的数据包转换为RTMP.这种方式是可能的,但同样,您需要在服务器和客户端都使用代理来转换每个数据包.请记住,RTMP是作为实时流协议制作的,因此使用HTTP作为代理会大大降低其性能.

还有RTMPT,它通过HTTP协议隧道传输RTMP数据包.它是为了绕过防火墙和大多数企业流量过滤,但它是adds latency并且总体上几乎没有支持.我认为是Red5 streaming server supports it.我还看到过防火墙阻止可疑HTTP数据包的情况,这可能会导致RTMPT出现一些问题,原因是数据包丢失和不稳定.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读