Nginx搭建rtmp流媒體伺服器
Nginx搭建rtmp流媒體伺服器
康林(2013年10月20日星期日)
1.1 視訊、音訊直播流(Live streaming of video/audio)
1.2 Flv、mp4視訊需求,從本地或HTTP播放(Video ondemand FLV/MP4, playing from local filesystem or HTTP)
1.3 支援分散式流中繼:推或拉模式(Stream relay support for distributed streaming: push & pullmodels
1.4 錄製FLVS流(Recording streams in multiple FLVs)
1.5 支援H264/AAC
1.6 線上用ffmpeg轉碼(Online transcoding with FFmpeg)
1.7 HLS (HTTP Live Streaming) 支援
1.8 基於http的操作(釋出、播放、錄製)(HTTP callbacks (publish/play/record/update etc))
1.9 在一定的事件中執行應用程式(Running external programs on certain events (exec)
1.10 HTTP control module forrecording audio/video and dropping clients
1.11 高階記憶體管理技術,快速流和低記憶體佔用(Advanced buffering techniques to keep memory allocations at aminimum level for faster streaming and low memory footprint)
1.12 實踐證明可以在下列產品中工作: Wirecast,FMS,Wowza, JWPlayer,FlowPlayer,StrobeMediaPlayback,ffmpeg,avconv,rtmpdump,flvstreamer and many more
1.13 Statistics in XML/XSL in machine-& human- readable form
1.14 Linux/FreeBSD/MacOS/Windows
Nginx:
官網:http://nginx.org/
下載:hg clone http://hg.nginx.org/nginx
nginx-rtmp-module:
進入nginx原始碼根目錄:
auto/configure--add-module=<path-to-nginx-rtmp-module>
make -f objs/Makefile
make -f objs/Makefile install
增加:http_ssl_module:
auto/configure--add-module=<path-to-nginx-rtmp-module>
--with-http_ssl_module
l Microsoft Visual C compiler.Microsoft Visual Studio® 8 and 10
l Msys
l Perl(如果要編譯OpenSSL並且nginx支援SLL),例如:ActivePerl 或 Strawberry Perl.
l PCRE,zlib and OpenSSLlibraries sources.
l 設定MSYS、Perl、VC環境變數
執行vc設定環境變數指令碼vcvarsall.bat(預設安裝路徑:C:\Program Files\MicrosoftVisual Studio 9.0\VC)
l 開始MSYS
l 建立編譯和庫目錄
mkdir objs
mkdir objs/lib
cd objs/lib
tar -xzf ../../pcre-8.32.tar.gz
tar -xzf ../../zlib-1.2.7.tar.gz
tar -xzf ../../openssl-1.0.1e.tar.gz
l 執行配置指令碼:
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\
--with-cc-opt=-DFD_SETSIZE=1024--with-pcre=objs/lib/pcre-8.32 \
--with-zlib=objs/lib/zlib-1.2.7--with-openssl=objs/lib/openssl-1.0.1e \
--with-select_module --with-http_ssl_module--with-ipv6
執行指令碼:
nmake –f objs/Makefile
同
linux
Windows下下列功能不支援:
l execs
l static pulls
l auto_push
windows下用的是select模式:
events{
worker_connections 30; #預設為(1024),windows預設為64,所以需要修改此值小於64
}
5 訪問URL格式:
rtmp://rtmp.example.com/app[/name]
app-應該是配置檔案中的application塊
name-可以為空
在原始碼要目下有個test目錄。其中有測試配置檔案和指令碼。
l 環境:
伺服器IP為:192.168.10.4。
安裝根路徑:/usr/local/nginx
在你的配置時,需要把IP換成你的伺服器IP或域名。
l 建立媒體資料夾:
mkdir /usr/local/nginx/vod/flvs
l 準備媒體檔案:
把媒體檔案 a.flv 複製到 /usr/local/nginx/vod/flvs目錄下。
l 準備網頁
下載後,解壓到:/usr/local/nginx/html/
建立測試頁面test.html,也放到上面目錄下。
<html>
<head>
<scriptsrc="/jwplayer/jwplayer.js"></script>
</head>
<body>
<divid='my-video'></div>
<scripttype='text/javascript'>
jwplayer('my-video').setup({
file:'rtmp://192.168.10.4/vod/a.flv',
width:'50%',
aspectratio:'3:2',
fallback:'false',
primary:'flash'
});
</script>
</body>
</html>
l 在nginx中配置http
#配置事件工作執行緒數
events {
worker_connections 30; #預設為(1024),windows預設為64,所以需要修改此值小於64
}
#配置http
http {
include mime.types;
default_type application/octet-stream;
#配置訪問web頁
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
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;
}
}
#配置rtmp狀態頁
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx/nginx-rtmp-module/; #在nginx-rtmp-module原始碼根目錄
}
}
}
#rtmp點播配置
rtmp {
server {
listen 1935;
chunk_size 4000;
application vod {
play /usr/local/nginx/vod/flvs; #點播媒體檔案存放目錄
}
}
}
l 啟動nginx
./nginx
l 從客戶端訪問網頁:
l 訪問rtmp狀態頁(非必須):
l
l 在配置檔案nginx.conf中加入
#rtmp直播配置
rtmp {
server {
listen 1935;
chunk_size 4000;
application live {
live on;
}
}
}
#配置訪問web頁
http {
include mime.types;
default_type application/octet-stream;
#配置訪問web頁
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
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;
}
#配置rtmp狀態頁
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx/nginx-rtmp-module/; #在nginx-rtmp-module原始碼根目錄
}
}
}
l 訪問rtmp狀態頁(非必須):
可以檢視rtmp流的統計情況
l 準備網頁
下載jwplayer:http://www.longtailvideo.com/players/jw-flv-player/
下載後,解壓到:/usr/local/nginx/html/
建立測試頁面test.html,也放到上面目錄下。
<html>
<head>
<scriptsrc="/jwplayer/jwplayer.js"></script>
</head>
<body>
<divid='my-video'></div>
<scripttype='text/javascript'>
jwplayer('my-video').setup({
file:'rtmp://192.168.0.128/live/test', #live是applicatioin,test是直播快取流檔案
width:'50%',
aspectratio:'3:2',
fallback:'false',
primary:'flash'
});
</script>
</body>
</html>
l 啟動服務
nginx
l 推流
用ffmpeg產生一個模擬直播源,向rtmp伺服器推送
ffmpeg –i/usr/local/nginx/vod/flvs/a.flv-strict -2 -c:v libx264 -c:a aac -f flv rtmp://192.168.10.4/live/test
注意,原始檔必須是H.264+AAC編碼的。
192.168.10.4是執行nginx的伺服器IP,l
ive是applicatioin,
test是直播快取流檔案,需要與配置檔案中的直播快取檔名一樣。
l 從客戶端訪問網頁:
相關推薦
Nginx搭建rtmp流媒體伺服器
Nginx搭建rtmp流媒體伺服器 康林(2013年10月20日星期日) 1 功能: 1.1 視訊、音訊直播流(Live streaming of video/audio) 1.2 Flv、mp4
nginx 搭建rtmp流媒體伺服器
本文是搭建nginx流媒體伺服器過程的筆記,方便自己或者有相關需求的人員參考。 註明: 主機系統:ubuntu16.04 測試主機IP:192.168.0.5 1. 下載PCRE 並安裝. 主頁地址: ftp://ftp.csx.cam.ac.uk/
用nginx-rtmp-module搭建rtmp流媒體伺服器
前言 利用開源的nginx-rtmp-module和Nginx搭建流媒體伺服器。Nginx是一個非常出色的http伺服器,nginx-rtmp-module是一個開源的Nginx擴充套件模組,擁有很多功能特性,像接收rtmp推流拉流,hls直播等: 1.RTMP/HLS/MPEG
Ubuntu16.04下配置nginx HTTPS + RTMP流媒體伺服器
Ubuntu16.04下配置HTTPS + rtmp伺服器 1. 在/usr目錄下建立資料夾nginx-install: cd /usr mkdir nginx-install cd nginx-install 2. &nbs
使用nginx搭建windows流媒體伺服器
準備工具: nginx ffmpeg ffmpeg只需要下載static版本。 下載nginx後,解壓nginx,然後修改conf/nginx-win.conf的內容為自己需要的配置,具體如下: #user nobody; # multiple work
開原始碼Window下搭建rtmp流媒體伺服器
有這樣需求,將攝像頭視屏釋出出去,並且需要在web網頁上通過Flash播放器播放。首先Flash被我所知道的所有瀏覽器所支援。如果是Activex控制元件。還需要被使用者額外安裝,而且一不小心還會出問題。但是Flash player預設是被安裝的。而且是比較穩定的。雖然開源
(九) nginx rtmp流媒體伺服器搭建
nginx 反向代理伺服器搭建(Ubuntu中):(除了nginx搭建流媒體伺服器(模組化配置),常用的還有red5(java配置)) nginx官網:http://nginx.org/ nginx中有很多模組,rtmp-module ffplay "rt
視訊演示-Ubuntu 14搭建Nginx-RTMP流媒體伺服器
(草稿版) 視訊演示地址:PART1-https://www.bilibili.com/video/av18139213/ 第一步、準備工作 (1)設定遠端連線Ubuntu root賬戶 apt-get install -y openssh-server 編輯vim /et
搭建nginx rtmp流媒體伺服器(超詳細)
阿里雲搭建rtmp流媒體伺服器,中間踩過一些坑,過程一步步紀錄的很詳細,以及碰到的一些問題。 一.工具下載 下載 OpenSl 下載解壓後目錄情況如下: 二. 編譯 1)編譯openssl 1.進入openssl目錄新建bin目錄,單
使用ffmpeg迴圈推流(迴圈讀取視訊檔案)推送EasyDSS RTMP流媒體伺服器的方法
需求 在做EasyDSS開發時,總是在測試推流效果。 有時候,我們想使用OBS進行推流測試,也可以,這很好。 以及其他RTMP推流工具。 但是,別忘了,還有ffmpeg這個神器。ffmpeg可以獲取各種視訊流,並推送給EasyDSS RTMP流媒體伺
搭建srs流媒體伺服器
方案: 搭建流媒體伺服器之後,採用ffmpeg推流(也可以使用obs推流),VLC拉流觀看 1、下載SRS原始碼 git clone https://github.com/ossrs/srs 2、安裝SRS cd srs/trunk ./configure
mac ox 搭建red5流媒體伺服器(含Demo)--學習記錄
1、下載最新版本的 red5 伺服器 下載頁面地址: 開啟找到最新的 釋出版本並下載 如下圖: 2、安裝 下載完,直接解壓檔案,將解壓後的目錄放個感覺合適的地方 設定環境變數 在 檔案 ~/.ba
javaCV開發詳解之4:轉流器實現(也可作為本地收流器、推流器,新增新增圖片及文字水印,視訊影象幀儲存),實現rtsp/rtmp/本地檔案轉發到rtmp流媒體伺服器(基於javaCV-FFMPEG)
javaCV系列文章: 補充篇: 歡迎大家積極開心的加入討論群 javacpp-ffmpeg: 前言: 本章基於javaCV實現轉流器和收流器功能,測試採用監控rtsp地址轉發至rtmp伺服器地址 新增openCV儲存圖片功能。 補充:
Ubuntu16.04 安裝搭建RED5流媒體伺服器
在網上看了不少安裝red5-server的方法,在我電腦上都好像安裝不成功,本來是很簡單的事,因為剛接觸,結果費了不少時間。這裡整理出ubuntu16.04 成功安裝的方法,以便給搭建一個參考。 (一)安裝JDK 1. 終端輸入:apt-cache sea
用vlc搭建簡單流媒體伺服器(UDP和TCP方式)
這段時間用到了流媒體資料傳輸的TCP和UDP方式,感覺vlc可以做這方面的demo,這裡總結下,也方便我以後查閱。 簡介 VLC不僅僅是個播放器,也可以作為流媒體伺服器使用。這個網上有相關的資料,我就不多說了。 宣告下本文用的VLC版本:2.0.3 用VLC搭建基於UDP的流媒體伺服器 流媒體伺服器大
Windows下環境搭建EasyDarwin流媒體伺服器及測試指南
相關網站: https://github.com/EasyDarwin/EasyDarwin/tree/master/EasyDarwin 一、準備工作,需要先下載我們需要的程式 1、EasyDarwin 下載地址:https://github.com/EasyDarwi
EasyDSS RTMP流媒體伺服器開發直播同時HLS錄影功能實現時移回放
EasyDSS商用流媒體伺服器解決方案是由EasyDarwin開源團隊原班人馬開發的一套集流媒體點播、轉碼與管理、直播、錄影、檢索、時移回看於一體的一套完整的商用流媒體伺服器解決方案,支援RTMP推流,RTMP/HLS分發。 EasyDarwin如何支援點播和
用vlc搭建簡單流媒體伺服器(UDP和TCP方式)-轉 rtsp很慢才能顯示
這段時間用到了流媒體資料傳輸的TCP和UDP方式,感覺vlc可以做這方面的demo,這裡總結下,也方便我以後查閱。 簡介 VLC不僅僅是個播放器,也可以作為流媒體伺服器使用。這個網上有相關的資料,我就不多說了。 宣告下本文用的VLC版本:2.0.3 用VLC搭建基於UDP的流媒體伺服器 流媒體伺服
用vlc搭建簡單流媒體伺服器(UDP方式)
簡介 VLC不僅僅是個播放器,也可以作為流媒體伺服器使用。這個網上有相關的資料,我就不多說了。 宣告下本文用的VLC版本:2.0.3 用VLC搭建基於UDP的流媒體伺服器 流媒體伺服器大多數是基於UDP的,這個在VLC中也有好幾種實現,我這裡只列出我用到的幾個。
EasyDSS RTMP流媒體伺服器的HTTP介面query url的C++實現方法
EasyDSS支援HTTP GET介面訪問,我們需要獲取url的各種引數資訊 比如http://ip:port/action?a=1&b=2&c=3 我們需要知道對應的a、b、c的值 這裡我們實現了簡單的query url,能滿足一般要求