• 用开源NGINX-RTMP-MODULE搭建FLASH直播环境


    用开源nginx-rtmp-module搭建flash直播环境

    1、将nginx和nginx-rtmp-module的源码包解压
    PS:nginx-rtmp-module网址
    https://github.com/arut/nginx-rtmp-module

    2、进入nginx的源代码目录,编译
    ./configure --add-module=<path-to-nginx-rtmp-module> --without-http_rewrite_module
    make
    make install


    3、写一个测试配置文件
    #user  nobody;
    worker_processes  1;

    error_log  logs/error.log debug;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;

    #pid        logs/nginx.pid;

    events {
        worker_connections  1024;
    }

    rtmp {
        server {
            listen 1935;

            chunk_size 4096;

            application myapp {
                live on;
            }
        }
    }

    http {
        server {
            listen      8080;

            location /stat {
                rtmp_stat all;
                rtmp_stat_stylesheet stat.xsl;
            }

            location /stat.xsl {
                root /home/arut-nginx-rtmp-module-e5d61f2/;
            }

            location / {
                root /home/arut-nginx-rtmp-module-e5d61f2/test/rtmp-publisher;
            }
        }
    }


    4、启动nginx
    /usr/local/nginx/sbin/nginx -c /home/arut-nginx-rtmp-module-e5d61f2/test/nginx.conf


    5、用ffmpeg产生一个模拟直播源,向rtmp服务器推送
    ffmpeg -re -i ~/2012.flv -f flv rtmp://192.168.11.75/myapp/test1
    注意,源文件必须是H.264+AAC编码的。192.168.11.75是运行nginx的服务器IP


    6、访问http://192.168.11.75:8080/stat,可以看到统计情况

    7、网页播放测试,用nginx-rtmp-module自带的一个例子修改,在test/rtmp-publisher目录下

    player.html

    <!DOCTYPE html>
    <html>
    <head>
        <title>RTMP Player</title>
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
            var flashVars = {
                streamer: 'rtmp://192.168.11.75/myapp',
                file:'test1'
            };
            swfobject.embedSWF("RtmpPlayer.swf", "rtmp-publisher", "500", "400", "9.0.0", 

    null, flashVars);
        </script>
    </head>
    <body>
        <div id="rtmp-publisher">
            <p>Flash not installed</p>
        </div>
    </body>
    </html>

    访问http://192.168.11.75:8080/player.html,可以播放。用三星P7500安卓平台也可以播放,就是

    播放大视频会很卡

    nginx-rtmp-module还有许多其他特性,例如支持FLV/MP4的点播、HLS直播、多worker工作模式、push and pull工作模式等,以后慢慢挖掘

  • 相关阅读:
    (转)Unity3D 开发优秀技术资源汇总
    (转)Unity3d通过Action注册事件,回调方法
    (转)Unity3D研究院之游戏架构脚本该如何来写(三十九)
    (转)Unity3D研究院之异步加载游戏场景与异步加载游戏资源进度条(三十一)
    Unity3D的主要类图
    C# 事件和Unity3D
    unity3d 场景配置文件生成代码
    497. Random Point in Non-overlapping Rectangles
    478. Generate Random Point in a Circle
    470. Implement Rand10() Using Rand7() (拒绝采样Reject Sampling)
  • 原文地址:https://www.cnblogs.com/fx2008/p/4226813.html
Copyright © 2020-2023  润新知