版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、網(wǎng)易視頻云:用Nginx搭建flv,mp4,hls流媒體服務(wù)器網(wǎng)易視頻云是網(wǎng)易傾力打造的一款基于云計(jì)算的分布式多媒體處理集群和專業(yè)音視頻技術(shù),提供穩(wěn)定流暢、低時延、高并發(fā)的視頻直播、錄制、存儲、轉(zhuǎn)碼及點(diǎn)播等音視頻的PAAS服務(wù),在線教育、遠(yuǎn)程醫(yī)療、娛樂秀場、在線金融等各行業(yè)及企業(yè)用戶只需經(jīng)過簡單的開發(fā)即可打造在線音視頻平臺。今天,網(wǎng)易視頻云就給大家分享關(guān)于用Nginx搭建flv,mp4,hls流媒體服務(wù)器的技術(shù)干貨!模塊:nginx_mod_h264_streaming(支持h264編碼MP4格式的視頻)模塊:http_flv_module (支持flv)模塊:http_mp4_mo
2、dule (支持mp4)模塊: nginx-rtmp-module (支持rtmp協(xié)議,也支持HLS)(1)模塊下載和解壓wget /download/nginx-1.6.0.tar.gzwget http:/h264.code-wget wget wget /source/openssl-1.0.1g.tar.gzwget -O nginx-rtmp-module.zip unzip nginx-rtmp-module.ziptar -zxvf nginx-1.6.0.tar.gztar -zxvf
3、nginx_mod_h264_streaming-2.2.7.tar.gztar -zxvf pcre-8.35.tar.gztar -zxvf zlib-1.2.8.tar.gztar -zxvf openssl-1.0.1g.tar.gz(2)配置命令,會生成makefile文件./configure -prefix=/usr/local/nginx -add-module=./nginx_mod_h264_streaming-2.2.7 -add-module=./nginx-rtmp-module -with-http_flv_module -with-http_mp4_module
4、-with-http_stub_status_module -with-http_ssl_module -with-pcre=./pcre-8.35 -with-zlib=./zlib-1.2.8 -with-debug(3)編譯和安裝makemake install(4)問題解決【1】如果在configure過程中出現(xiàn)以下錯誤:/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ngx_streaming_handler:/root/nginx_mod_h264_streaming
5、-2.2.7/src/ngx_http_streaming_module.c:158: error: ngx_http_request_t has no member named zero_in_urimake1: * objs/addon/src/ngx_http_h264_streaming_module.o Error 1make1: Leaving directory /root/nginx-0.8.54'make: * build Error 2那么將src/ngx_http_streaming_module.c文件中以下代碼刪除或者是注釋掉就可以了:/* TODO: Win
6、32 */if (r->zero_in_uri)return NGX_DECLINED;如果你沒有對這個文件做個更改,那么應(yīng)該在源碼的第157-161行。這個問題是由于版本原因引起,在此不再討論。修改完之后,記得先執(zhí)行make clean,然后再進(jìn)行重新執(zhí)行configure、make,最后make install?!?】如果在編譯過程中出現(xiàn)以下錯誤:cc1: warnings being treated as errors那么修改/nginx-1.6.0/objs/Makefile文件CFLAGS = -pipe -O -W -Wall -Wpointer-ar
7、ith -Wno-unused-parameter -Werror -g -D_LARGEFILE_SOURCE -DBUILDING_NGINX -I./nginx-rtmp-module-master把上面的 -Werror去掉,不把warnning當(dāng)作error處理(5)Nginx的配置#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs
8、/error.log info;#pid logs/nginx.pid;events worker_connections 1024;rtmp server listen 1935;chunk_size 4000;# video on demand for flv filesapplication vod play /usr/local/nginx/html/flv;# video on demand for mp4 filesapplication vod2 play /usr/loc
9、al/nginx/html/mp4;application hls live on;hls on;hls_path /tmp/hls;# MPEG-DASH is similar to HLSapplication dash live on;dash on;dash_path /tmp/dash;http include mime.types;default_type application/octet-stream;#log_format main '$remote_addr
10、- $remote_user $time_local "$request" '# '$status $body_bytes_sent "$http_referer" '#
11、60; '"$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
12、60; on;server # in case we have another web server on port 80listen 8080;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main; location / root html;index index.html index.htm;#error_page 404
13、0; /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;location .mp4$ mp4;location .flv$ flv;# This URL provides
14、RTMP statistics in XMLlocation /stat rtmp_stat all;rtmp_stat_stylesheet stat.xsl;location /stat.xsl # XML stylesheet to view RTMP stats.# Copy stat.xsl wherever you want# and put the full directory path hereroot /var/www/;location /hls # Serve HLS fragmentstypes application/vnd.apple.mpegurl m3u8;vi
15、deo/mp2t ts;#where the m3u8 and ts files arealias /usr/local/nginx/html/hls; #live streaming setting #root /tmp;#add_header Cache-Control no-cache;location /dash # Serve DASH fragmentsroot /tmp;a
16、dd_header Cache-Control no-cache;(6)用ffmpeg生成測試序列【1】對于mp4文件,生成moov信息前移的mp4格式,適合流媒體播放。ffmpeg -i /home/administrator/Videos/Amelia_720p.mp4 -c:v libx264 -c:a libvo_aacenc -f mp4 -movflags faststart /home/administrator/Videos/moovfront.mp4【2】對于flv文件,用flvmeta工具在metadata中注入關(guān)鍵幀的信息,支持隨意拖動播放。ffmpe
17、g -i/home/administrator/Videos/Baroness.mp4 -vcodec libx264 -acodec libvo_aacenc -b:a 128k -ar 44100 -ac 2 -f flv /home/administrator/Videos/Baroness.flvflvmeta -U -m -k /home/administrator/Videos/Baroness.flv /home/administrator/Videos/Baroness_meta.flv【3】對于flv的播放,或者直接生成f4v格式的文件。ffmp
18、eg -i /home/administrator/Videos/sample/vc1_1080p.mkv -acodec libfdk_aac -ac 2 -b:a 128k -ar 48000 -vcodec libx264 -pix_fmt yuv420p -profile:v main -level 32 -b:v 1000K -r 29.97 -g 30 -s 960x540 -f f4v /home/administrator/Videos/hddvd_1000k.f4v(7)Nginx啟動,重啟,關(guān)閉命令start nginx 開啟 nginx -s sto
19、p 快速關(guān)閉 nginx -s quit 完全關(guān)閉 nginx -s reload 修改過配置文件,快速關(guān)閉舊的,開啟新服務(wù) nginx -s reopen 重新打開日志文件 停止操作停止操作是通過向nginx進(jìn)程發(fā)送信號來進(jìn)行的步驟1:查詢nginx主進(jìn)程號ps -ef | grep nginx在進(jìn)程列表里 面找master進(jìn)程,它的編號就是主進(jìn)程號了。步驟2:發(fā)送信號從容停止Nginx:kill -QUIT 主進(jìn)程號快速停止Nginx:kill -TERM 主進(jìn)程號強(qiáng)制停止N
20、ginx:pkill -9 nginx另外, 若在nginx.conf配置了pid文件存放路徑則該文件存放的就是Nginx主進(jìn)程號,如果沒指定則放在nginx的logs目錄下。有了pid文 件,我們就不用先查詢Nginx的主進(jìn)程號,而直接向Nginx發(fā)送信號了,命令如下:kill -信號類型 '/usr/nginx/logs/nginx.pid'平滑重啟如果更改了配置就要重啟Nginx,要先關(guān)閉Nginx再打開?不是的,可以向Nginx 發(fā)送信號,平滑重啟。平滑重啟命令:kill -HUP 主進(jìn)程號或進(jìn)程號文件路徑或者使用 /usr/nginx/sbin/nginx -s reload注意,修改了配置文件后最好先檢查一下修改過的配置文件是否正 確,以免重啟后Nginx出現(xiàn)錯誤影響服務(wù)器穩(wěn)定運(yùn)行。判斷Nginx配置是否正確命令如下:nginx -t -c /usr/nginx/conf/nginx.conf或者/usr/nginx/sbin/nginx -t(8)播放測試啟動nginx后測試:05/player.swf?type=http&file=test1.flv說明: #我的ip是
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度文化產(chǎn)業(yè)投資基金合同擔(dān)保與風(fēng)險防范3篇
- 二零二五年度葡萄酒年份酒年份酒鑒定技術(shù)合作合同4篇
- 2025年度綠色生態(tài)葡萄園承包經(jīng)營權(quán)轉(zhuǎn)讓合同書
- 二零二五年度2025年二手房買賣按揭合同范本專業(yè)檢索
- 2025版新能源汽車典當(dāng)貸款合同模板3篇
- 2025-2030全球單細(xì)胞RNA文庫制備試劑盒行業(yè)調(diào)研及趨勢分析報告
- 2025-2030全球商業(yè)碳捕捉技術(shù)行業(yè)調(diào)研及趨勢分析報告
- 2025年全球及中國LED 燈帶罩行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 二零二五年度美發(fā)培訓(xùn)中心場地租賃與教學(xué)合作合同
- 食品加工廠生產(chǎn)合作合同
- 2025年度院感管理工作計(jì)劃(后附表格版)
- 勵志課件-如何做好本職工作
- 化肥銷售工作計(jì)劃
- 2024浙江華數(shù)廣電網(wǎng)絡(luò)股份限公司招聘精英18人易考易錯模擬試題(共500題)試卷后附參考答案
- 2024年山東省濟(jì)南市中考英語試題卷(含答案解析)
- 2024年社區(qū)警務(wù)規(guī)范考試題庫
- 2025中考英語作文預(yù)測:19個熱點(diǎn)話題及范文
- 第10講 牛頓運(yùn)動定律的綜合應(yīng)用(一)(講義)(解析版)-2025年高考物理一輪復(fù)習(xí)講練測(新教材新高考)
- 靜脈治療護(hù)理技術(shù)操作標(biāo)準(zhǔn)(2023版)解讀 2
- 2024年全國各地中考試題分類匯編(一):現(xiàn)代文閱讀含答案
- GB/T 30306-2024家用和類似用途飲用水處理濾芯
評論
0/150
提交評論