nginx flv/rtmp/hls for Windows x64

本文介紹Nginx with nginx-http-flv-module配置(win64位)




環(huán)境

win 7 64位跨嘉,openssl-1.0.2r,nginx-http-flv-module


下載

1于置、下載以下工具芯侥,并依次安裝:
  • 下載VS2010+VS2010 SP1
  • msys-1.0.11.exe
  • ActicePerl-5.24.2.2403-MSWin32-x64-403863.exe
  • mercurial-4.3.1-x64.msi
  • nasm-2.12.02rc9-installer-x64.exe(32位需要用唉工,64位不需要)
  • sed-4.2.1-setup.exe
  • 下載配套的所需庫代碼PCRE,zlib 和 OpenSSL libraries sources
  • 下載nginx-http-flv-module:https://github.com/winshining/nginx-http-flv-module

以上工具需要確保加入到了環(huán)境變量(控制面板\系統(tǒng)和安全\系統(tǒng)\高級系統(tǒng)設(shè)置\環(huán)境變量)。

2、獲取Nginx源碼:

打開cmd命令葬荷,切換到Mercurial安裝根目錄,執(zhí)行命令:

hg clone http://hg.nginx.org/nginx

下載成功后會在Mercurial安裝目錄下急前,創(chuàng)建nginx源代碼文件夾醒陆。

3、添加依賴資源包:

使用MSYS工具裆针,在nginx源代碼分別創(chuàng)建objs/lib文件夾刨摩,將下載好的nginx-http-flv-module寺晌、openssl、pcre澡刹、zlib分別解壓在lib文件夾下面


編譯

1呻征、生成makefile文件,用于c++編譯器:

繼續(xù)使用MSYS工具罢浇,返回到nginx源代碼根目錄陆赋,執(zhí)行以下腳本:

auto/configure --with-cc=cl --builddir=objs --prefix= \
--conf-path=conf/nginx.conf --pid-path=logs/nginx.pid \
--http-log-path=logs/access.log --error-log-path=logs/error.log \
--sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp \
--http-proxy-temp-path=temp/proxy_temp \
--http-fastcgi-temp-path=temp/fastcgi_temp \
--http-scgi-temp-path=temp/scgi_temp \
--http-uwsgi-temp-path=temp/uwsgi_temp \
--with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs/lib/pcre-8.40 \
--with-zlib=objs/lib/zlib-1.2.11 --with-openssl=objs/lib/openssl-1.0.2r \
--with-select_module --with-http_ssl_module --add-module=objs/lib/nginx-http-flv-module

成功后輸出以下:


1、修改nginx\auto\lib\openssl\makefile.msvc文件:

將VC-WIN32改為VC-WIN64A嚷闭,將ms\do_ms 改為ms\do_win64a

修改objs\Makefile文件:將“-WX”刪除攒岛,否則nmake時會報錯“nginx error:c2220:警告被視為錯誤 - 沒有生成object文件”

2、編譯Nginx源碼:

使用VS2010 x64 Win64命令工具胞锰,切換到Nginx根目錄灾锯,執(zhí)行以下命令:

nmake -f objs/Makefile

編譯成功后,生成可執(zhí)行程序nginx.exe


配置

1嗅榕、

在nginx.exe所在文件夾下創(chuàng)建創(chuàng)建conf,html,logs,temp目錄屈暗,其中conf,html可從src中拷貝华临。

2、

在html目錄下創(chuàng)建nginx-http-flv-module文件夾,并將objs\lib\nginx-http-flv-module\下的test文件夾及stat.xsl拷貝過來阔墩。

3甫匹、

修改conf/nginx.conf配置文件称近,修改后內(nèi)容如下:

#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        
        location /flv {
            flv_live on;
            chunked_transfer_encoding on;       
        }

        location /hls {      
           types{    
             application/vnd.apple.mpegurl m3u8;    
             video/mp2t ts;    
           }    
        alias /test;    
        expires -1;    
        }
        
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html/nginx-http-flv-module/;
        }

        location /control {
            rtmp_control all;
        }

        location /rtmp-publisher {
            root html/nginx-http-flv-module/test;
        }
        
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root html/nginx-http-flv-module/test/www;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

rtmp {  
    server {  
        listen 1935;  
        chunk_size 4000;  
        application hls { 
            live on;
            hls on;
            hls_path /test;
            hls_fragment 1s;
        }  
    }  
}
4纯赎、啟動nginx

運行nginx.exe

在瀏覽器中輸入ip:port,顯示如下:

在瀏覽器中輸入ip:port/status嘲碱,顯示如下監(jiān)控信息:

5金砍、推流:

推送設(shè)置地址rtmp://ip:1935/hls/url,其中ip為服務(wù)器地址麦锯,hls為application名恕稠,url自定義(必填)。

6扶欣、拉流:

FLV:http://ip:80/flv?port=1935&app=hls&stream=url
RTMP:rtmp://ip:1935/hls/url
HLS:http://ip:80/hls/url.m3u8


示例

VLC拉流RTMP:

Safari拉流HLS:

VLC拉流FLV:


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末鹅巍,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子料祠,更是在濱河造成了極大的恐慌骆捧,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,490評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件髓绽,死亡現(xiàn)場離奇詭異敛苇,居然都是意外死亡,警方通過查閱死者的電腦和手機顺呕,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,581評論 3 395
  • 文/潘曉璐 我一進(jìn)店門枫攀,熙熙樓的掌柜王于貴愁眉苦臉地迎上來括饶,“玉大人,你說我怎么就攤上這事来涨⊥佳妫” “怎么了?”我有些...
    開封第一講書人閱讀 165,830評論 0 356
  • 文/不壞的土叔 我叫張陵蹦掐,是天一觀的道長技羔。 經(jīng)常有香客問我,道長卧抗,這世上最難降的妖魔是什么藤滥? 我笑而不...
    開封第一講書人閱讀 58,957評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮颗味,結(jié)果婚禮上超陆,老公的妹妹穿的比我還像新娘牺弹。我一直安慰自己浦马,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,974評論 6 393
  • 文/花漫 我一把揭開白布张漂。 她就那樣靜靜地躺著晶默,像睡著了一般。 火紅的嫁衣襯著肌膚如雪航攒。 梳的紋絲不亂的頭發(fā)上磺陡,一...
    開封第一講書人閱讀 51,754評論 1 307
  • 那天,我揣著相機與錄音漠畜,去河邊找鬼币他。 笑死,一個胖子當(dāng)著我的面吹牛憔狞,可吹牛的內(nèi)容都是我干的蝴悉。 我是一名探鬼主播,決...
    沈念sama閱讀 40,464評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼瘾敢,長吁一口氣:“原來是場噩夢啊……” “哼拍冠!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起簇抵,我...
    開封第一講書人閱讀 39,357評論 0 276
  • 序言:老撾萬榮一對情侶失蹤庆杜,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后碟摆,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體晃财,經(jīng)...
    沈念sama閱讀 45,847評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,995評論 3 338
  • 正文 我和宋清朗相戀三年典蜕,在試婚紗的時候發(fā)現(xiàn)自己被綠了断盛。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片雏逾。...
    茶點故事閱讀 40,137評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖郑临,靈堂內(nèi)的尸體忽然破棺而出栖博,到底是詐尸還是另有隱情,我是刑警寧澤厢洞,帶...
    沈念sama閱讀 35,819評論 5 346
  • 正文 年R本政府宣布仇让,位于F島的核電站,受9級特大地震影響躺翻,放射性物質(zhì)發(fā)生泄漏丧叽。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,482評論 3 331
  • 文/蒙蒙 一公你、第九天 我趴在偏房一處隱蔽的房頂上張望踊淳。 院中可真熱鬧,春花似錦陕靠、人聲如沸迂尝。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,023評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽垄开。三九已至,卻和暖如春税肪,著一層夾襖步出監(jiān)牢的瞬間溉躲,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,149評論 1 272
  • 我被黑心中介騙來泰國打工益兄, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留锻梳,地道東北人。 一個月前我還...
    沈念sama閱讀 48,409評論 3 373
  • 正文 我出身青樓净捅,卻偏偏與公主長得像疑枯,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子灸叼,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,086評論 2 355

推薦閱讀更多精彩內(nèi)容