使用 NGINX-RTMP 从远程计算机播放视频

Play a video from remote computer using NGINX-RTMP

我正在尝试使用带有 rtmp 协议的 nginx-rtmp 流式传输视频。 我创建了一个 index.html 并在其上嵌入了带有 rtmp url 的 JWPlayer。 在本地主机上,我可以从浏览器播放视频,但是当我尝试同样的事情时,我可以从同一本地网络中的另一台计算机播放视频(在浏览器中打开 index.html url 是 http://172.16.40.162:8080 )我得到一条错误信息。 但是当我尝试使用 vlc(rtmp url : rtmp://172.16.40.162/vod/test)时它起作用了。
这里的代码是 index.html

    <!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>VoD Example</title>
        <script src="http://jwpsrv.com/library/s7iNvOAyEeSMdQ4AfQhyIQ.js"></script>
    </head>

<body>
    <div id='videotest'></div>
    <script type='text/javascript'>
        jwplayer('videotest').setup({
        file: 'rtmp://localhost/vod/test',
        width: '50%',
        aspectratio: '16:9'
        });
</script>
</body>
</html>

nginx.conf

    #user  nobody;
worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8080;
        server_name  localhost;

        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /usr/local/nginx/html;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

rtmp {
    server {
        listen 1935;
    notify_method get;
    chunk_size 8192;

        application vod {
        allow play all;
        wait_video on;
            play /var/www/Videos;
        push rtmp://localhost/vod/test;
        }
    }
}

我在 :

上收到这些消息

acces.log

    172.16.40.148 - - [16/Apr/2015:13:08:33 +0100] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
172.16.40.148 [16/Apr/2015:13:19:29 +0100] PLAY "vod" "test" "" - 382 3660906 "" "LNX 9,0,124,2" (1m 58s)
127.0.0.1 [16/Apr/2015:13:51:47 +0100] PLAY "vod" "test" "" - 483 3669724 "http://172.16.40.162:8080/" "LNX 11,2,202,457" (1m 50s)

error.log

2015/04/16 13:07:06 [notice] 3771#0: using the "epoll" event method
    2015/04/16 13:07:06 [notice] 3771#0: nginx/1.5.0
    2015/04/16 13:07:06 [notice] 3771#0: built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
    2015/04/16 13:07:06 [notice] 3771#0: OS: Linux 2.6.32-504.12.2.el6.x86_64
    2015/04/16 13:07:06 [notice] 3771#0: getrlimit(RLIMIT_NOFILE): 1024:4096
    2015/04/16 13:07:06 [notice] 3772#0: start worker processes
    2015/04/16 13:07:06 [notice] 3772#0: start worker process 3773
    2015/04/16 13:08:41 [info] 3773#0: *3 client closed connection while waiting for request, client: 172.16.40.148, server: 0.0.0.0:8080

关于我使用的视频的信息(我执行了ffmpeg -i test.flv)

    Input #0, flv, from 'test.flv':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    encoder         : Lavf56.30.100
  Duration: 00:01:50.03, start: 0.060000, bitrate: 270 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 30.30 fps, 30 tbr, 1k tbn, 60 tbc
    Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16p, 64 kb/s

index.html 中将 file: 'rtmp://localhost/vod/test' 替换为 file: 'rtmp://172.16.40.162/vod/test'

JWPlayer Flash 将从客户端机器请求URL。使用 localhost 显然不起作用,因为它会在同一台计算机上查找流。