vps上下載了一些mp4格式的視頻,點擊是直接下載,不能直接在線播放, 所以google了一下有個nginx_mod_h264_streaming的模塊。
下載
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
編譯安裝
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=/usr/local/src/pcre-8.10 --add-module=/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/nginx/ --add-module=/usr/local/src/nginx_mod_h264_streaming-2.2.7
make
make install
出錯了
.... In file included from /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_h264_streaming_module.c:2: /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’ : /usr/local/src/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 `/usr/local/src/nginx-0.8.54' make: *** [build] Error 2
解決錯誤:
因為在新版本的nginx中廢棄了zero_in_uri這個flag,稍微修改一下nginx_mod_h264_streaming的源代碼
vim /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c
把158到161行注釋掉
157 /* TODO: Win32 */ 158 //if (r->zero_in_uri) 159 //{ 160 // return NGX_DECLINED; 161 //}
然后再make就正常了,make install 完成安裝 配置nginx使之支持mp4 在nginx配置文件中加入
location ~ \.mp4$ { mp4; }
重啟nginx
/etc/init.d/nginx restart
效果來了

reference
