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

posted @ 2012-11-16 15:31  shuaixf  阅读(9930)  评论(0编辑  收藏  举报