1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 安裝必要套件 apt-get install build-essential libpcre3 libpcre3-dev libssl-dev # 下載 tar 安裝檔案 cd /tmp wget http://nginx.org/download/nginx-1.7.3.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip # 安裝 nginx tar -zxvf nginx-1.7.3.tar.gz unzip master.zip cd nginx-1.7.3/ ./configure --with-http_ssl_module --with-http_xslt_module --add-module=../nginx-rtmp-module-master make make install # 編輯 nginx 設定檔案 vim /usr/local/nginx/conf/nginx.conf rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; } } } # 啟動 nginx service /usr/local/nginx/sbin/nginx |
此時可使用 OBS 傳送Stremaing進行測試
OBS設定 => 廣播
模式:直播串流
串流服務:Custom
伺服器:rtmp://[nginx 伺服器ip]/live
播放路徑:test
便可以透過VLC或是Flash player以下面連結進行播放
rtmp://[nginx 伺服器ip]/live
內嵌Flash Player的網頁範例如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Video.js RTMP Example - jsFiddle demo</title> <link rel="stylesheet" type="text/css" href="http://vjs.zencdn.net/4.2/video-js.css"> <script type='text/javascript' src="http://vjs.zencdn.net/4.2/video.js"></script> <style type='text/css'> </style> </head> <body> <video id="my_video_1" class="video-js vjs-default-skin" controls autoplay="autoplay" preload="auto" width="640" height="264" data-setup='{ "techOrder": ["flash"] }'> <source src="rtmp://<?php echo $_SERVER['SERVER_ADDR'];?>/live/<?php echo $_GET['name'];?>" type='rtmp/mp4'> </video> </body> </html> |