FLV 的另類實現方法
還有一種方法是通過nginx_mod_h264_streaming來實現的,我們看一下。
下載nginx_mod_h264_streaming模組
[root@flv ~]wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz [root@flv ~]# tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz |
修改Makefile
可能需要修改Makefile檔案,根據實際情況修改:
[root@mail nginx_mod_h264_streaming-2.2.7]# vi Makefile
# vim:noexpandtab:sw=2 ts=2
.PHONY: all dist install clean
HOME=$(shell echo ~) PWD=$(shell pwd) #NGINX=$(HOME)/nginx-0.8.29/ #NGINX=$(HOME)/nginx-0.7.33/ NGINX=/root/nginx-1.0.2/
VERSION=`./version.sh` DIST_NAME=nginx_mod_h264_streaming-$(VERSION)
all: cd $(NGINX) && ./configure --sbin-path=/usr/local/sbin --add-module=/root/nginx_mod_h264_streaming-2.2.7 --with-debug --with-http_flv_module make --directory=$(NGINX)
……//省略 |
注意黑體字部分,它使用了HttpFlvStreamModule模組,即--with-http_flv_module引數。
編譯安裝
[root@flv nginx-1.0.2]# ./configure --prefix=/usr/local/nginx-1.0.2-h264-flv --add-module=/root/nginx_mod_h264_streaming-2.2.7 [root@flv nginx-1.0.2]#make [root@flv nginx-1.0.2]#make install |
如果在configure過程中出現以下錯誤:
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’: /root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’ make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1 make[1]: Leaving directory `/root/nginx-0.8.54' make: *** [build] Error 2
|
那麼將src/ngx_http_streaming_module.c檔案中以下程式碼刪除或者是註釋掉就可以了:
/* TODO: Win32 */ if (r->zero_in_uri) { return NGX_DECLINED; } |
如果你沒有對這個檔案做個更改,那麼應該在原始碼的第157-161行。這個問題是由於版本原因引起,在此不再討論。
修改完之後,記得先執行make clean,然後再進行重新執行configure、make,最後make install。
nginx_mod_h264_streaming模組的用法
另外,我們再看一下src/ngx_http_streaming_module.c這個檔案,看以下部分:
[root@flv nginx_mod_h264_streaming-2.2.7]# vi src/ngx_http_streaming_module.c
#if 0 /* Mod-H264-Streaming configuration
server { listen 82; server_name localhost;
location ~ \.mp4$ { root /var/www; mp4; } }
*/
/* Mod-Smooth-Streaming configuration
server { listen 82; server_name localhost;
rewrite ^(.*/)?(.*)\.([is])sm/[Mm]anifest$ $1$2.$3sm/$2.ismc last; rewrite ^(.*/)?(.*)\.([is])sm/QualityLevels\(([0-9]+)\)/Fragments\((.*)=([0-9]+)\)(.*)$ $1$2.$3sm/$2.ism?bitrate=$4&$5=$6 last;
location ~ \.ism$ { root /var/www; ism; } } */ #endif |
新增配置
在這個原始碼檔案中嵌入了該模組的用法,注意黑體字部分,因此我們的配置檔案應該這麼寫:
server { listen 80; server_name 192.168.1.105; root html; limit_rate_after 5m; limit_rate 512k; index index.html; location ~ \.flv$ { root /var/www/flv; mp4; } location ~ \.mp4$ { root /var/www/mp4; mp4; }
} |
訪問測試
啟動Nginx,訪問http://flv.xx.com/player.swf?type=http&file=4315.mp4
如果我們在執行configure時使用了--with-http_flv_module選項,例如:
[root@flv nginx-1.0.2]# ./configure --prefix=/usr/local/nginx-1.0.2-mp4-flv --add-module=/root/nginx_mod_h264_streaming-2.2.7 --with-http_flv_module |
那麼在Nginx的配置檔案中可以這麼配置:
location ~ \.flv$ { root /var/www/flv; flv; } location ~ \.mp4$ { root /var/www/mp4; mp4; } |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27043155/viewspace-735288/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- AppBoxFuture(八): 另類的ORM實現APPORM
- 另類用法 hyperf/session 實現 API tokenSessionAPI
- win電腦快速關機的另類方法
- 使用flv.js實現flv格式的監控視訊流播放JS
- 敏捷與彈性:迎接新現實的另類投資報告敏捷
- vue3.0 載入json的“另類”方法(非ajax)VueJSON
- 實現類的註冊方法
- 解決 "Script Error" 的另類思路Error
- Flutter混合開發——一種另類卻高效的的原生View嵌入方法FlutterView
- 想睡得更好,這三種“另類”方法試過了沒?
- 另類 RobotFramework 使用法Framework
- Azure KeyVault(四)另類在 .NET Core 上操作 Secrets 的類庫方法-----Azure.Security.KeyVault.Secrets
- [20180627]truncate table的另類恢復.txt
- HttpServletRequest中的方法是哪個類實現的?HTTPServlet
- 另類遠控:木馬借道商業級遠控軟體的隱藏執行實現
- 一種獲取SAP HANA資料庫表條目數的另類方法資料庫
- java中介面多個實現類,如何指定實現類,根據子類型別選擇實現方法Java型別
- [20181212]truncate的另類恢復5.txt
- 《有殺氣童話2》:另類童話世界開啟的另類MMO | 遊戲產品觀察遊戲
- obs+node-media-server+flv.js實現錄播和直播ServerJS
- 海康RTSP轉flv並實現h5頁面播放H5
- [20180630]truncate table的另類恢復2.txt
- 技術之外的工程師另類成長指南工程師
- string類的實現
- Vue3實現元件級基類的幾種方法Vue元件
- java關於繼承父類,需要實現父類中的構造方法Java繼承構造方法
- 類轉json的基類實現JSON
- 《騎馬與砍殺》:CRPG精神的另類復活
- 驚喜!一個檔案多個【請求類】的另類寫法
- H5開發類似rpx實現方法H5
- Map類及其主要的實現類
- python 介面實現類的Python
- 宮鬥遊戲,另類財富密碼遊戲密碼
- delphi 判斷類是否實現介面,獲取類實現的介面
- FLV(Flash Video)IDE
- Promise 方法的實現Promise
- 賓士大G遇到自家的越野車:土豪的“另類”大玩具
- 一個菜雞技術人員,很另類的總結
- 另類投資:AI藝術品定價指北AI