Nginx支持mp4格式的視頻播放


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 functionngx_streaming_handler:
/usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error:ngx_http_request_thas
 no member namedzero_in_urimake[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

轉:http://lxneng.com/posts/160


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM